diff --git a/CHANGELOG.md b/CHANGELOG.md index 855edb1d7c5..83a5925def3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [next] +## [6.5.2] + - chore(): Reduce some verbose code [#10311](https://github.com/fabricjs/fabric.js/pull/10311) - ci(): Test node 22 again [#10310](https://github.com/fabricjs/fabric.js/pull/10310) - chore(TS): Try to remove all TS-ERROR directives [#10309](https://github.com/fabricjs/fabric.js/pull/10309) diff --git a/dist/index.min.js b/dist/index.min.js index a86f19e4062..692bb219301 100644 --- a/dist/index.min.js +++ b/dist/index.min.js @@ -1,2 +1,2 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).fabric={})}(this,(function(t){"use strict";function e(t,e,s){return(e=function(t){var e=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||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function s(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 i(t){for(var i=1;i=0)continue;s[i]=t[i]}return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i=0||{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function n(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class o{constructor(){e(this,"browserShadowBlurConstant",1),e(this,"DPI",96),e(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),e(this,"perfLimitSizeTotal",2097152),e(this,"maxCacheSideLimit",4096),e(this,"minCacheSideLimit",256),e(this,"disableStyleCopyPaste",!1),e(this,"enableGLFiltering",!0),e(this,"textureSize",4096),e(this,"forceGLPutImageData",!1),e(this,"cachesBoundsOfCurve",!1),e(this,"fontPaths",{}),e(this,"NUM_FRACTION_DIGITS",4)}}const a=new class extends o{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=i(i({},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 o,s=(null==t?void 0:t.reduce(((t,s)=>(t[s]=e[s],t)),{}))||e;this.configure(s)}},h=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis.testPrecision(e,t))),e.getExtension("WEBGL_lose_context").loseContext(),h("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const g={};let f;const p=()=>f||(f={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new d,dispose(){},copyPasteData:g}),m=()=>p().document,v=()=>p().window,y=()=>{var t;return Math.max(null!==(t=a.devicePixelRatio)&&void 0!==t?t:v().devicePixelRatio,1)};const _=new class{constructor(){e(this,"charWidthsCache",{}),e(this,"boundsOfCurveCache",{})}getFontCache(t){let{fontFamily:e,fontStyle:s,fontWeight:i}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});const r=this.charWidthsCache[e],n="".concat(s.toLowerCase(),"_").concat((i+"").toLowerCase());return r[n]||(r[n]={}),r[n]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){const{perfLimitSizeTotal:e}=a,s=Math.sqrt(e*t);return[Math.floor(s),Math.floor(e/s)]}};const x="6.5.1";function C(){}const b=Math.PI/2,S=2*Math.PI,w=Math.PI/180,T=Object.freeze([1,0,0,1,0,0]),O=16,k=.4477152502,D="center",M="left",P="top",E="bottom",A="right",j="none",F=/\r?\n/,L="moving",R="scaling",I="rotating",B="rotate",X="skewing",Y="resizing",W="modifyPoly",V="modifyPath",G="changed",z="scale",H="scaleX",N="scaleY",U="skewX",q="skewY",K="fill",J="stroke",Q="modified",Z="json",$="svg";const tt=new class{constructor(){this[Z]=new Map,this[$]=new Map}has(t){return this[Z].has(t)}getClass(t){const e=this[Z].get(t);if(!e)throw new c("No class registered for ".concat(t));return e}setClass(t,e){e?this[Z].set(e,t):(this[Z].set(t.type,t),this[Z].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[$].get(t)}setSVGClass(t,e){this[$].set(null!=e?e:t.type.toLowerCase(),t)}};const et=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 st{constructor(){e(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!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 t in this.__eventListeners)this._removeEventListener(t);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 t=0;t{const s=t.indexOf(e);return-1!==s&&t.splice(s,1),t},rt=t=>{if(0===t)return 1;switch(Math.abs(t)/b){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},nt=t=>{if(0===t)return 0;const e=t/b,s=Math.sign(t);switch(e){case 1:return s;case 2:return 0;case 3:return-s}return Math.sin(t)};class ot{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 ot(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new ot(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new ot(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new ot(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new ot(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new ot(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new ot(this.x/t.x,this.y/t.y)}scalarDivide(t){return new ot(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.xt.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 ot(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 ot(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new ot(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 ot(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at;const s=nt(t),i=rt(t),r=this.subtract(e);return new ot(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 ot(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 at=new ot(0,0),ht=t=>!!t&&Array.isArray(t._objects);function ct(t){class s extends t{constructor(){super(...arguments),e(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),s=0;sthis._onObjectAdded(t))),i}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis._onObjectAdded(t))),this._objects.length}remove(){const t=this._objects,e=[];for(var s=arguments.length,i=new Array(s),r=0;r{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;st.isType(...e)))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,e){return!!this._objects.includes(t)||!!e&&this._objects.some((e=>e instanceof s&&e.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])&&(it(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(it(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 it(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 it(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(it(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;s1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new ot(e,s),h=a.add(new ot(i,r));for(let t=this._objects.length-1;t>=0;t--){const e=this._objects[t];e.selectable&&e.visible&&(n&&e.intersectsWithRect(a,h)||e.isContainedWithinRect(a,h)||n&&e.containsPoint(a)||n&&e.containsPoint(h))&&o.push(e)}return o}}return s}class lt extends st{_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 ut(t){return v().requestAnimationFrame(t)}function dt(t){return v().cancelAnimationFrame(t)}let gt=0;const ft=()=>gt++,pt=()=>{const t=m().createElement("canvas");if(!t||void 0===t.getContext)throw new c("Failed to create `canvas` element");return t},mt=()=>m().createElement("img"),vt=t=>{const e=pt();return e.width=t.width,e.height=t.height,e},yt=(t,e,s)=>t.toDataURL("image/".concat(e),s),_t=t=>t*w,xt=t=>t/w,Ct=t=>t.every(((t,e)=>t===T[e])),bt=(t,e,s)=>new ot(t).transform(e,s),St=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 ot(t[4],t[5]).transform(s,!0);return s[4]=-i,s[5]=-r,s},wt=(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]],Tt=(t,e)=>t.reduceRight(((t,s)=>s&&t?wt(s,t,e):s||t),void 0)||T.concat(),Ot=t=>{let[e,s]=t;return Math.atan2(s,e)},kt=t=>{const e=Ot(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:xt(e),scaleX:i,scaleY:r,skewX:xt(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},Dt=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Mt(){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=_t(t),r=rt(i),n=nt(i);return[r,n,-n,r,e?e-(r*e-n*s):0,s?s-(n*e+r*s):0]}const Pt=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Et=t=>Math.tan(_t(t)),At=t=>[1,0,Et(t),1,0,0],jt=t=>[1,Et(t),0,1,0,0],Ft=t=>{let{scaleX:e=1,scaleY:s=1,flipX:i=!1,flipY:r=!1,skewX:n=0,skewY:o=0}=t,a=Pt(i?-e:e,r?-s:s);return n&&(a=wt(a,At(n),!0)),o&&(a=wt(a,jt(o),!0)),a},Lt=t=>{const{translateX:e=0,translateY:s=0,angle:i=0}=t;let r=Dt(e,s);i&&(r=wt(r,Mt({angle:i})));const n=Ft(t);return Ct(n)||(r=wt(r,n)),r},Rt=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 l("loadImage"));const n=mt();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 c("Error loading ".concat(n.src)))},s&&(n.crossOrigin=s),n.src=t):a()}))},It=function(t){let{signal:e,reviver:s=C}=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=>tt.getClass(t.type).fromObject(t,{signal:e}).then((e=>(s(t,e),n.push(e),e)))))).then(i).catch((t=>{n.forEach((t=>{t.dispose&&t.dispose()})),r(t)})).finally((()=>{e&&e.removeEventListener("abort",r)}))}))},Bt=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&&tt.has(t.type)?It([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)}))}))},Xt=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce(((e,s)=>(s in t&&(e[s]=t[s]),e)),{})},Yt=(t,e)=>Object.keys(t).reduce(((s,i)=>(e(t[i],i,t)&&(s[i]=t[i]),s)),{}),Wt={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"},Vt=(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),Gt=(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+(e0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},Ht=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),Nt=t=>{let[e,s,i,r=1]=t;const n=Math.round(.3*e+.59*s+.11*i);return[n,n,n,r]};class Ut{constructor(t){if(e(this,"isUnrecognised",!1),t)if(t instanceof Ut)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 in Wt&&(t=Wt[t]),"transparent"===t?[255,255,255,0]:Ut.sourceFromHex(t)||Ut.sourceFromRgb(t)||Ut.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=Gt(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=Gt(...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(Ht(t)).concat(Ht(e)).concat(Ht(s)).concat(Ht(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Nt(this.getSource())),this}toBlackWhite(t){const[e,,,s]=Nt(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof Ut||(t=new Ut(t));const e=this.getSource(),s=t.getSource(),[i,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 Ut.fromRgba(t)}static fromRgba(t){return new Ut(Ut.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[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,zt(e[4])]}}static fromHsl(t){return Ut.fromHsla(t)}static fromHsla(t){return new Ut(Ut.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const s=(Ut.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,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=Vt(e,t,s+1/3),o=Vt(e,t,s),a=Vt(e,t,s-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*a),zt(e[4])]}static fromHex(t){return new Ut(Ut.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map((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")?xt(s):e.includes("turn")?360*s:s}}const qt=(t,e)=>parseFloat(Number(t).toFixed(e)),Kt=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;const s=/\D{0,2}$/.exec(t),i=parseFloat(t),r=a.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}},Jt=t=>{const[e,s]=t.trim().split(" "),[i,r]=(n=e)&&n!==j?[n.slice(1,4),n.slice(5,8)]:n===j?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:s||"meet",alignX:i,alignY:r}},Qt=t=>"matrix("+t.map((t=>qt(t,a.NUM_FRACTION_DIGITS))).join(" ")+")",Zt=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 Ut(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,'" '):"")},$t=t=>!!t&&void 0!==t.toLive,te=t=>!!t&&"function"==typeof t.toObject,ee=t=>!!t&&void 0!==t.offsetX&&"source"in t,se=t=>!!t&&"function"==typeof t._renderText,ie=t=>!!t&&"multiSelectionStacking"in t;function re(t){const e=t&&ne(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 ne=t=>t.ownerDocument||null,oe=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},ae=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))},he=(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 ce(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=j,t}class le{constructor(t){e(this,"_originalCanvasStyle",void 0),e(this,"lower",void 0);const s=this.createLowerCanvas(t);this.lower={el:s,ctx:s.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&void 0!==s.getContext?t:t&&m().getElementById(t)||pt();var s;if(e.hasAttribute("data-fabric"))throw new c("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;ae(s,i,t,e)}setCSSDimensions(t){he(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&ne(t),i={left:0,top:0};if(!s)return i;const r=(null===(e=oe(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=re(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(){p().dispose(this.lower.el),delete this.lower}}const ue={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...T]};class de extends(ct(lt)){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 de.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}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new le(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;i0&&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&&(h("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?y():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=i({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=bt(t,St(i));i[0]=e,i[3]=e;const n=bt(r,i);i[4]+=s.x-n.x,i[5]+=s.y-n.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new ot(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 ot(-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=ut((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,s=St(this.viewportTransform),i=bt({x:0,y:0},s),r=bt({x:t,y:e},s),n=i.min(r),o=i.max(r);return this.vptCoords={tl:n,tr:new ot(o.x,n.y),bl:new ot(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(dt(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const s=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const s=this.viewportTransform;t.save(),t.transform(...s),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let s=0,i=e.length;s!t.excludeFromExport)).map((s=>this._toObject(s,t,e)))},this.__serializeBgOverlay(t,e)),r?{clipPath:r}: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 $t(n)?n.excludeFromExport||(s.background=n.toObject(e)):n&&(s.background=n),$t(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('\n')),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push("\n"),this._setSVGBgOverlayColor(s,"overlay"),this._setSVGBgOverlayImage(s,"overlayImage",e),s.push(""),s.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('\n','\n')}_setSVGHeader(t,e){const s=e.width||"".concat(this.width),i=e.height||"".concat(this.height),r=a.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(qt(-t[4]/t[0],r)," ").concat(qt(-t[5]/t[3],r)," ").concat(qt(this.width/t[0],r)," ").concat(qt(this.height/t[3],r),'" ')}else o='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("\n',"Created with Fabric.js ",x,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(ft()),'\n').concat(e.toClipPathSVG(t.reviver),"\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if($t(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?Qt(i):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},s=a.fontPaths;this._objects.forEach((function e(s){t.push(s),ht(s)&&s._objects.forEach(e)})),t.forEach((t=>{if(!se(t))return;const{styles:i,fontFamily:r}=t;!e[r]&&s[r]&&(e[r]=!0,i&&Object.values(i).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\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($t(s)){const i=s.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?Qt(St(this.viewportTransform)):"";t.push('\n'))}else t.push('\n")}loadFromJSON(t,e){let{signal:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new c("`json` is undefined"));const i="string"==typeof t?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:o,overlayImage:a,overlay:h,clipPath:l}=i,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([It(r,{reviver:e,signal:s}),Bt({backgroundImage:n,backgroundColor:o,overlayImage:a,overlayColor:h,clipPath:l},{signal:s})]).then((t=>{let[e,s]=t;return this.clear(),this.add(...e),this.set(i),this.set(s),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=vt(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 yt(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=vt({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}),et.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"#")}}e(de,"ownDefaults",ue);const ge=["touchstart","touchmove","touchend"];const fe=t=>{const e=re(t.target),s=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new ot(s.clientX+e.left,s.clientY+e.top)},pe=t=>ge.includes(t.type)||"touch"===t.pointerType,me=t=>{t.preventDefault(),t.stopPropagation()},ve=t=>{let e=0,s=0,i=0,r=0;for(let n=0,o=t.length;ni||!n)&&(i=o),(or||!n)&&(r=a),(axe(t,wt(e,t.calcOwnMatrix())),xe=(t,e)=>{const s=kt(e),{translateX:i,translateY:n,scaleX:o,scaleY:a}=s,h=r(s,ye),c=new ot(i,n);t.flipX=!1,t.flipY=!1,Object.assign(t,h),t.set({scaleX:o,scaleY:a}),t.setPositionByOrigin(c,D,D)},Ce=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},be=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}),Se=(t,e,s)=>{const i=t/2,r=e/2,n=[new ot(-i,-r),new ot(i,-r),new ot(-i,r),new ot(i,r)].map((t=>t.transform(s))),o=ve(n);return new ot(o.width,o.height)},we=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:T;return wt(St(arguments.length>1&&void 0!==arguments[1]?arguments[1]:T),t)},Te=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(we(e,s))},Oe=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(we(e,s),!0)},ke=(t,e,s)=>{const i=we(e,s);return xe(t,wt(i,t.calcOwnMatrix())),i},De=(t,e)=>{var s;const{transform:{target:r}}=e;null===(s=r.canvas)||void 0===s||s.fire("object:".concat(t),i(i({},e),{},{target:r})),r.fire(t,e)},Me={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Pe=t=>"string"==typeof t?Me[t]:t-.5,Ee="not-allowed";function Ae(t){return Pe(t.originX)===Pe(D)&&Pe(t.originY)===Pe(D)}function je(t){return.5-Pe(t)}const Fe=(t,e)=>t[e],Le=(t,e,s,i)=>({e:t,transform:e,pointer:new ot(s,i)});function Re(t,e){const s=t.getTotalAngle()+xt(Math.atan2(e.y,e.x))+360;return Math.round(s%360/45)}function Ie(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,D,D,s,i):new ot(t.left,t.top);return(t.angle?e.rotate(-_t(t.angle),r):e).subtract(n)}(o,new ot(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 Be=(t,e,s,i)=>{const{target:r,offsetX:n,offsetY:o}=e,a=s-n,h=i-o,c=!Fe(r,"lockMovementX")&&r.left!==a,l=!Fe(r,"lockMovementY")&&r.top!==h;return c&&r.set(M,a),l&&r.set(P,h),(c||l)&&De(L,Le(t,e,s,i)),c||l};class Xe{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",s=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):j,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=Zt(K,this.fill);return[Zt(J,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(Qt(s));return"".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(ft()),p='\n').concat(a.toClipPathSVG(s),"\n")),c&&g.push("\n"),g.push("\n");const m=[n,h,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,$t(u)&&g.push(u.toSVG(this)),$t(l)&&g.push(l.toSVG(this)),d&&g.push(d.toSVG(this)),a&&g.push(p),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==K?' paint-order="'.concat(this.paintFirst,'" '):""}}function Ye(t){return new RegExp("^("+t.join("|")+")\\b","i")}var We;const Ve=String.raw(We||(We=n(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Ge="http://www.w3.org/2000/svg",ze=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Ve+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Ve+"))?\\s+(.*)"),He={cx:M,x:M,r:"radius",cy:P,y:P,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"},Ne="font-size",Ue="clip-path",qe=Ye(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Ke=Ye(["symbol","image","marker","pattern","view","svg"]),Je=Ye(["symbol","g","a","svg","clipPath","defs"]),Qe=new RegExp("^\\s*("+Ve+"+)\\s*,?\\s*("+Ve+"+)\\s*,?\\s*("+Ve+"+)\\s*,?\\s*("+Ve+"+)\\s*$"),Ze=new ot(1,0),$e=new ot,ts=(t,e)=>t.rotate(e),es=(t,e)=>new ot(e).subtract(t),ss=t=>t.distanceFrom($e),is=(t,e)=>Math.atan2(as(t,e),hs(t,e)),rs=t=>is(Ze,t),ns=t=>t.eq($e)?t:t.scalarDivide(ss(t)),os=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ns(new ot(-t.y,t.x).scalarMultiply(e?1:-1))},as=(t,e)=>t.x*e.y-t.y*e.x,hs=(t,e)=>t.x*e.x+t.y*e.y,cs=(t,e,s)=>{if(t.eq(e)||t.eq(s))return!0;const i=as(e,s),r=as(e,t),n=as(s,t);return i>=0?r>=0&&n<=0:!(r<=0&&n>=0)},ls="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",us=new RegExp("(?:\\s|^)"+ls+ls+"("+Ve+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ds{constructor(t){const e="string"==typeof t?ds.parseShadow(t):t;Object.assign(this,ds.ownDefaults,e),this.id=ft()}static parseShadow(t){const e=t.trim(),[,s=0,i=0,r=0]=(us.exec(e)||[]).map((t=>parseFloat(t)||0));return{color:(e.replace(us,"")||"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=ts(new ot(this.offsetX,this.offsetY),_t(-t.angle)),s=new Ut(this.color);let i=40,r=40;return t.width&&t.height&&(i=100*qt((Math.abs(e.x)+this.blur)/t.width,a.NUM_FRACTION_DIGITS)+20,r=100*qt((Math.abs(e.y)+this.blur)/t.height,a.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\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=ds.ownDefaults;return this.includeDefaultValues?t:Yt(t,((t,s)=>t!==e[s]))}static async fromObject(t){return new this(t)}}e(ds,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),e(ds,"type","shadow"),tt.setClass(ds,"shadow");const gs=(t,e,s)=>Math.max(t,Math.min(e,s)),fs=[P,M,H,N,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",U,q],ps=[K,J,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ms={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:M,originY:P,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:K,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},vs=(t,e,s,i)=>(tt*Math.pow(2,10*(i-=1))*Math.sin((i*r-e)*S/s),_s=(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,xs=(t,e,s,i)=>(t/=i)<1/2.75?s*(7.5625*t*t)+e:t<2/2.75?s*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?s*(7.5625*(t-=2.25/2.75)*t+.9375)+e:s*(7.5625*(t-=2.625/2.75)*t+.984375)+e,Cs=(t,e,s,i)=>s-xs(i-t,0,s,i)+e;var bs=Object.freeze({__proto__:null,defaultEasing:_s,easeInBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*(t/=i)*t*((r+1)*t-r)+e},easeInBounce:Cs,easeInCirc:(t,e,s,i)=>-s*(Math.sqrt(1-(t/=i)*t)-1)+e,easeInCubic:(t,e,s,i)=>s*(t/i)**3+e,easeInElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h}=vs(r,s,n,1.70158);return-ys(o,a,h,t,i)+e},easeInExpo:(t,e,s,i)=>0===t?e:s*2**(10*(t/i-1))+e,easeInOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return(t/=i/2)<1?s/2*(t*t*((1+(r*=1.525))*t-r))+e:s/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInOutBounce:(t,e,s,i)=>t(t/=i/2)<1?-s/2*(Math.sqrt(1-t**2)-1)+e:s/2*(Math.sqrt(1-(t-=2)*t)+1)+e,easeInOutCubic:(t,e,s,i)=>(t/=i/2)<1?s/2*t**3+e:s/2*((t-2)**3+2)+e,easeInOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(2===(t/=i/2))return e+s;n||(n=i*(.3*1.5));const{a:o,s:a,p:h,c:c}=vs(r,s,n,1.70158);return t<1?-.5*ys(o,a,h,t,i)+e:o*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*S/h)*.5+c+e},easeInOutExpo:(t,e,s,i)=>0===t?e:t===i?e+s:(t/=i/2)<1?s/2*2**(10*(t-1))+e:s/2*-(2**(-10*--t)+2)+e,easeInOutQuad:(t,e,s,i)=>(t/=i/2)<1?s/2*t**2+e:-s/2*(--t*(t-2)-1)+e,easeInOutQuart:(t,e,s,i)=>(t/=i/2)<1?s/2*t**4+e:-s/2*((t-=2)*t**3-2)+e,easeInOutQuint:(t,e,s,i)=>(t/=i/2)<1?s/2*t**5+e:s/2*((t-2)**5+2)+e,easeInOutSine:(t,e,s,i)=>-s/2*(Math.cos(Math.PI*t/i)-1)+e,easeInQuad:(t,e,s,i)=>s*(t/=i)*t+e,easeInQuart:(t,e,s,i)=>s*(t/=i)*t**3+e,easeInQuint:(t,e,s,i)=>s*(t/i)**5+e,easeInSine:(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,easeOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*((t=t/i-1)*t*((r+1)*t+r)+1)+e},easeOutBounce:xs,easeOutCirc:(t,e,s,i)=>s*Math.sqrt(1-(t=t/i-1)*t)+e,easeOutCubic:(t,e,s,i)=>s*((t/i-1)**3+1)+e,easeOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h,c:c}=vs(r,s,n,1.70158);return o*2**(-10*t)*Math.sin((t*i-a)*S/h)+c+e},easeOutExpo:(t,e,s,i)=>t===i?e+s:s*-(2**(-10*t/i)+1)+e,easeOutQuad:(t,e,s,i)=>-s*(t/=i)*(t-2)+e,easeOutQuart:(t,e,s,i)=>-s*((t=t/i-1)*t**3-1)+e,easeOutQuint:(t,e,s,i)=>s*((t/i-1)**5+1)+e,easeOutSine:(t,e,s,i)=>s*Math.sin(t/i*b)+e});const Ss=()=>!1;class ws{constructor(t){let{startValue:s,byValue:i,duration:r=500,delay:n=0,easing:o=_s,onStart:a=C,onChange:h=C,onComplete:c=C,abort:l=Ss,target:u}=t;e(this,"_state","pending"),e(this,"durationProgress",0),e(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=n,this.easing=o,this._onStart=a,this._onChange=h,this._onComplete=c,this._abort=l,this.target=u,this.startValue=s,this.byValue=i,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((()=>ut(t)),this.delay):ut(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),ut(this.tick)))}register(){et.push(this)}unregister(){et.remove(this)}abort(){this._state="aborted",this.unregister()}}const Ts=["startValue","endValue"];class Os extends ws{constructor(t){let{startValue:e=0,endValue:s=100}=t;super(i(i({},r(t,Ts)),{},{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 ks=["startValue","endValue"];class Ds extends ws{constructor(t){let{startValue:e=[0],endValue:s=[100]}=t;super(i(i({},r(t,ks)),{},{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 Ms=["startValue","endValue","easing","onChange","onComplete","abort"],Ps=(t,e,s,i)=>e+s*(1-Math.cos(t/i*b)),Es=t=>t&&((e,s,i)=>t(new Ut(e).toRgba(),s,i));class As extends ws{constructor(t){let{startValue:e,endValue:s,easing:n=Ps,onChange:o,onComplete:a,abort:h}=t,c=r(t,Ms);const l=new Ut(e).getSource(),u=new Ut(s).getSource();super(i(i({},c),{},{startValue:l,byValue:u.map(((t,e)=>t-l[e])),easing:n,onChange:Es(o),onComplete:Es(a),abort:Es(h)}))}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),gs(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 js(t){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(t)?new Ds(t):new Os(t);return e.start(),e}function Fs(t){const e=new As(t);return e.start(),e}class Ls{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!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=es(e,s),n=es(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 ot(t).setX(Math.min(t.x-1,...e.map((t=>t.x))));let i=0;for(let r=0;r4&&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 Ls("Intersection").append(new ot(t.x+e*o,t.y+e*a)):new Ls}if(0===d||0===g){const o=r||n||Ls.isPointContained(t,s,i)||Ls.isPointContained(e,s,i)||Ls.isPointContained(s,t,e)||Ls.isPointContained(i,t,e);return new Ls(o?"Coincident":void 0)}return new Ls("Parallel")}static intersectSegmentLine(t,e,s,i){return Ls.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return Ls.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 Ls,n=s.length;for(let o,a,h,c=0;c0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,s){return Ls.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new Ls,i=t.length,r=[];for(let n=0;n0&&r.length===t.length?new Ls("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 ot(r.x,i.y),o=new ot(i.x,r.y);return Ls.intersectPolygonPolygon(t,[i,n,r,o])}}class Rs extends lt{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?bt(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=bt(t,St(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new ot(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=>bt(e,t)))}return r}intersectsWithRect(t,e){return"Intersection"===Ls.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Ls.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}=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 Ls.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;if(this.intersectsWithRect(t,e))return!0;return 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 ve(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(H,t),this._set(N,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?xt(Ot(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||T.concat()}calcACoords(){const t=Mt({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=Dt(e,s),r=wt(i,t),n=this._getTransformedDimensions(),o=n.x/2,a=n.y/2;return{tl:bt({x:-o,y:-a},r),tr:bt({x:o,y:-a},r),bl:bt({x:-o,y:a},r),br:bt({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,Pe(this.originX),Pe(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=wt(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=Lt(i);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new ot(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=i({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 r=s,n=0;this.strokeUniform&&(r=0,n=s);const o=e.width+r,a=e.height+r;let h;return h=0===e.skewX&&0===e.skewY?new ot(o*e.scaleX,a*e.scaleY):Se(o,a,Ft(e)),h.scalarAdd(n)}translateToGivenOrigin(t,e,s,i,r){let n=t.x,o=t.y;const a=Pe(i)-Pe(e),h=Pe(r)-Pe(s);if(a||h){const t=this._getTransformedDimensions();n+=a*t.x,o+=h*t.y}return new ot(n,o)}translateToCenterPoint(t,e,s){if(e===D&&s===D)return t;const i=this.translateToGivenOrigin(t,e,s,D,D);return this.angle?i.rotate(_t(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,D,D,e,s);return this.angle?i.rotate(_t(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?bt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new ot(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(),M,P)}}const Is=["type"],Bs=["extraParam"];let Xs=class t extends Rs{static getDefaults(){return t.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){h("warn","Setting type has no effect",t)}constructor(s){super(),e(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(s)}_createCacheCanvas(){this._cacheCanvas=pt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=a.maxCacheSideLimit,r=a.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=a.perfLimitSizeTotal)return ec&&(t.zoomX/=e/c,t.width=c,t.capped=!0),s>l&&(t.zoomY/=s/l,t.height=l,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),s=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:s+2,height:i+2,zoomX:t.x,zoomY:t.y,x:s,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,s=this._limitCacheSize(this._getCacheCanvasDimensions()),i=a.minCacheSideLimit,r=s.width,n=s.height,o=s.zoomX,h=s.zoomY,c=r!==t.width||n!==t.height,l=this.zoomX!==o||this.zoomY!==h;if(!t||!e)return!1;let u,d,g=c||l,f=0,p=0,m=!1;if(c){const t=this._cacheCanvas.width,e=this._cacheCanvas.height,o=r>t||n>e;m=o||(r<.9*t||n<.9*e)&&t>i&&e>i,o&&!s.capped&&(r>i||n>i)&&(f=.1*r,p=.1*n)}return se(this)&&this.path&&(g=!0,m=!0,f+=this.getHeightOfLine(0)*this.zoomX,p+=this.getHeightOfLine(0)*this.zoomY),!!g&&(m?(t.width=Math.ceil(r+f),t.height=Math.ceil(n+p)):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height)),u=s.x/2,d=s.y/2,this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(o,h),this.zoomX=o,this.zoomY=h,!0)}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 ot(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=kt(this.calcTransformMatrix());return new ot(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){t.transform(i)})),e.parentClipPaths.push(t),t.absolutePositioned){const t=St(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()),!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,$t(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&&($t(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)||T,o=r*i,h=n*i,c=e.nonScaling?new ot(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*a.browserShadowBlurConstant*(o+h)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*o*c.x,t.shadowOffsetY=e.offsetY*h*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!$t(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===J?(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=vt({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 ot(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(tt.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=be(this),s=this.group,i=this.shadow,r=Math.abs,n=t.enableRetinaScaling?y():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new de(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Ce(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&ke(this,this.getViewportTransform()),this.setCoords();const h=pt(),c=this.getBoundingRect(),l=this.shadow,u=new ot;if(l){const t=l.blur,e=l.nonScaling?new ot(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 ot(f.width/2,f.height/2),D,D);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 yt(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;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 r=t.split("."),n=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:h,onComplete:c}=s,l=i(i({},s),{},{target:this,startValue:null!=a?a:r.reduce(((t,e)=>t[e]),this),endValue:e,abort:null==o?void 0:o.bind(this),onChange:(t,e,s)=>{r.reduce(((e,s,i)=>(i===r.length-1&&(e[s]=t),e[s])),this),h&&h(t,e,s)},onComplete:(t,e,s)=>{this.setCoords(),c&&c(t,e,s)}});return n?Fs(l):js(l)}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-1&&n>o}toObject(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]);let s;const r=a.NUM_FRACTION_DIGITS,{clipPath:n,fill:o,stroke:h,shadow:c,strokeDashArray:l,left:u,top:d,originX:g,originY:f,width:p,height:m,strokeWidth:v,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:S,scaleX:w,scaleY:T,angle:O,flipX:k,flipY:D,opacity:M,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:L,skewY:R}=this;n&&!n.excludeFromExport&&(s=n.toObject(e.concat("inverted","absolutePositioned")));const I=t=>qt(t,r),B=i(i({},Xt(this,e)),{},{type:this.constructor.type,version:x,originX:g,originY:f,left:I(u),top:I(d),width:I(p),height:I(m),fill:te(o)?o.toObject():o,stroke:te(h)?h.toObject():h,strokeWidth:I(v),strokeDashArray:l?l.concat():l,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:I(S),scaleX:I(w),scaleY:I(T),angle:I(O),flipX:k,flipY:D,opacity:I(M),shadow:c?c.toObject():c,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:I(L),skewY:I(R)},s?{clipPath:s}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Yt(t,((t,e)=>{if(e===M||e===P||"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=r(t,Is),s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:i}=s,n=r(s,Bs);return Bt(e,n).then((t=>i?(delete t[i],new this(e[i],t)):new this(t)))}static fromObject(t,e){return this._fromObject(t,e)}};e(Xs,"stateProperties",fs),e(Xs,"cacheProperties",ps),e(Xs,"ownDefaults",ms),e(Xs,"type","FabricObject"),e(Xs,"colorProperties",[K,J,"backgroundColor"]),e(Xs,"customProperties",[]),tt.setClass(Xs),tt.setClass(Xs,"object");const Ys=(t,e,s)=>(r,n,o,a)=>{const h=e(r,n,o,a);return h&&De(t,i(i({},Le(r,n,o,a)),s)),h};function Ws(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 Vs=Ys(Y,Ws(((t,e,s,i)=>{const r=Ie(e,e.originX,e.originY,s,i);if(Pe(e.originX)===Pe(D)||Pe(e.originX)===Pe(A)&&r.x<0||Pe(e.originX)===Pe(M)&&r.x>0){const{target:t}=e,s=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=Ae(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 Gs(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?J:K,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,S,!1),t[h](),c&&t.stroke(),t.restore()}function zs(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?J:K,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(_t(d)),t["".concat(h,"Rect")](-l,-u,n,o),c&&t.strokeRect(-l,-u,n,o),t.restore()}class Hs{constructor(t){e(this,"visible",!0),e(this,"actionName",z),e(this,"angle",0),e(this,"x",0),e(this,"y",0),e(this,"offsetX",0),e(this,"offsetY",0),e(this,"sizeX",0),e(this,"sizeY",0),e(this,"touchSizeX",0),e(this,"touchSizeY",0),e(this,"cursorStyle","crosshair"),e(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)&&Ls.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}positionHandler(t,e,s,i){return new ot(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,r,n){const o=Tt([Dt(s,i),Mt({angle:t}),Pt((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new ot(-.5,-.5).transform(o),tr:new ot(.5,-.5).transform(o),br:new ot(.5,.5).transform(o),bl:new ot(-.5,.5).transform(o)}}render(t,e,s,i,r){if("circle"===((i=i||{}).cornerStyle||r.cornerStyle))Gs.call(this,t,e,s,i,r);else zs.call(this,t,e,s,i,r)}}const Ns=(t,e,s)=>s.lockRotation?Ee:e.cursorStyle,Us=Ys(I,Ws(((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(Fe(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=xt(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){const i=qs(t,s);if(Ks(s,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return Ee;const r=Re(s,e);return"".concat(Js[r],"-resize")};function Zs(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const n=e.target,o=r.by,a=qs(t,n);let h,c,l,u,d,g;if(Ks(n,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,l=e.scaleY*e.gestureScale;else{if(h=Ie(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),Fe(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);Ae(e)&&(c*=2,l*=2),e.signX!==d&&"y"!==o&&(e.originX=je(e.originX),c*=-1,e.signX=d),e.signY!==g&&"x"!==o&&(e.originY=je(e.originY),l*=-1,e.signY=g)}const f=n.scaleX,p=n.scaleY;return o?("x"===o&&n.set(H,c),"y"===o&&n.set(N,l)):(!Fe(n,"lockScalingX")&&n.set(H,c),!Fe(n,"lockScalingY")&&n.set(N,l)),f!==n.scaleX||p!==n.scaleY}const $s=Ys(R,Ws(((t,e,s,i)=>Zs(t,e,s,i)))),ti=Ys(R,Ws(((t,e,s,i)=>Zs(t,e,s,i,{by:"x"})))),ei=Ys(R,Ws(((t,e,s,i)=>Zs(t,e,s,i,{by:"y"})))),si=["target","ex","ey","skewingSide"],ii={x:{counterAxis:"y",scale:H,skew:U,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:N,skew:q,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},ri=["ns","nesw","ew","nwse"],ni=(t,e,s)=>{if(0!==e.x&&Fe(s,"lockSkewingY"))return Ee;if(0!==e.y&&Fe(s,"lockSkewingX"))return Ee;const i=Re(s,e)%4;return"".concat(ri[i],"-resize")};function oi(t,e,s,n,o){const{target:a}=s,{counterAxis:h,origin:c,lockSkewing:l,skew:u,flip:d}=ii[t];if(Fe(a,l))return!1;const{origin:g,flip:f}=ii[h],p=Pe(s[g])*(a[f]?-1:1),m=-Math.sign(p)*(a[d]?-1:1),v=.5*-((0===a[u]&&Ie(s,D,D,n,o)[t]>0||a[u]>0?1:-1)*m)+.5,y=Ys(X,Ws(((e,s,i,n)=>function(t,e,s){let{target:i,ex:n,ey:o,skewingSide:a}=e,h=r(e,si);const{skew:c}=ii[t],l=s.subtract(new ot(n,o)).divide(new ot(i.scaleX,i.scaleY))[t],u=i[c],d=h[c],g=Math.tan(_t(d)),f="y"===t?i._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:i._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*l*a/Math.max(f,1)+g,m=xt(Math.atan(p));i.set(c,m);const v=u!==i[c];if(v&&"y"===t){const{skewX:t,scaleX:e}=i,s=i._getTransformedDimensions({skewY:u}),r=i._getTransformedDimensions(),n=0!==t?s.x/r.x:1;1!==n&&i.set(H,n*e)}return v}(t,s,new ot(i,n)))));return y(e,i(i({},s),{},{[c]:v,skewingSide:m}),n,o)}const ai=(t,e,s,i)=>oi("x",t,e,s,i),hi=(t,e,s,i)=>oi("y",t,e,s,i);function ci(t,e){return t[e.canvas.altActionKey]}const li=(t,e,s)=>{const i=ci(t,s);return 0===e.x?i?U:N:0===e.y?i?q:H:""},ui=(t,e,s)=>ci(t,s)?ni(0,e,s):Qs(t,e,s),di=(t,e,s,i)=>ci(t,e.target)?hi(t,e,s,i):ti(t,e,s,i),gi=(t,e,s,i)=>ci(t,e.target)?ai(t,e,s,i):ei(t,e,s,i),fi=()=>({ml:new Hs({x:-.5,y:0,cursorStyleHandler:ui,actionHandler:di,getActionName:li}),mr:new Hs({x:.5,y:0,cursorStyleHandler:ui,actionHandler:di,getActionName:li}),mb:new Hs({x:0,y:.5,cursorStyleHandler:ui,actionHandler:gi,getActionName:li}),mt:new Hs({x:0,y:-.5,cursorStyleHandler:ui,actionHandler:gi,getActionName:li}),tl:new Hs({x:-.5,y:-.5,cursorStyleHandler:Qs,actionHandler:$s}),tr:new Hs({x:.5,y:-.5,cursorStyleHandler:Qs,actionHandler:$s}),bl:new Hs({x:-.5,y:.5,cursorStyleHandler:Qs,actionHandler:$s}),br:new Hs({x:.5,y:.5,cursorStyleHandler:Qs,actionHandler:$s}),mtr:new Hs({x:0,y:-.5,actionHandler:Us,cursorStyleHandler:Ns,offsetY:-40,withConnection:!0,actionName:B})}),pi=()=>({mr:new Hs({x:.5,y:0,actionHandler:Vs,cursorStyleHandler:ui,actionName:Y}),ml:new Hs({x:-.5,y:0,actionHandler:Vs,cursorStyleHandler:ui,actionName:Y})}),mi=()=>i(i({},fi()),pi());class vi extends Xs{static getDefaults(){return i(i({},super.getDefaults()),vi.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),vi.ownDefaults),this.setOptions(t)}static createControls(){return{controls:fi()}}_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(z))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=Dt(e.x,e.y),i=Mt({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=wt(s,i),n=wt(t,r),o=wt(n,[1/t[0],0,0,1/t[3],0,0]),a=this.group?kt(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)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(_t(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 r=i({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},s);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:s,hasControls:r}=this,n=i({hasBorders:s,hasControls:r},e),o=this.getViewportTransform(),a=n.hasBorders,h=n.hasControls,c=wt(o,this.calcTransformMatrix()),l=kt(c);t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(_t(this.group?l.angle:this.angle)),a&&this.drawBorders(t,l,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const t=Se(this.width,this.height,Ft(e)),s=this.isStrokeAccountedForInDimensions()?at:(this.strokeUniform?(new ot).scalarAdd(this.canvas?this.canvas.getZoom():1):new ot(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:r,cornerDashArray:n,cornerColor:o}=this,a=i({cornerStrokeColor:r,cornerDashArray:n,cornerColor:o},e);t.setTransform(s,0,0,s,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((e,s)=>{if(e.getVisibility(this,s)){const i=this.oCoords[s];e.render(t,i.x,i.y,a,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 yi(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}e(vi,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class _i extends vi{}yi(_i,[Xe]),tt.setClass(_i),tt.setClass(_i,"object");const xi=(t,e,s,i)=>{const r=2*(i=Math.round(i))+1,{data:n}=t.getImageData(e-i,s-i,r,r);for(let t=3;t0)return!1}return!0};class Ci{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new ot(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new ot(1/this.options.scaleX,1/this.options.scaleY):new ot(1,1)}createSideVector(t,e){const s=es(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 ot(t);return e.y+=e.x*Math.tan(_t(this.options.skewY)),e.x+=e.y*Math.tan(_t(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const bi=new ot;class Si extends Ci{static getOrthogonalRotationFactor(t,e){const s=e?is(t,e):rs(t);return Math.abs(s)2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),r=os(i),n=Si.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,s*n)}projectBevel(){const t=[];return(this.alpha%S==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?ss(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return ss(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new ot(Si.getOrthogonalRotationFactor(this.bisector),Si.getOrthogonalRotationFactor(new ot(this.bisector.y,this.bisector.x)));return[new ot(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new ot(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach((i=>{cs(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 ot(Math.tan(_t(i)),Math.tan(_t(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 ot(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 ot(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=>{cs(i,t,e)&&s.push(this.applySkew(this.A).add(i))})),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%S==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=as(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 wi extends Ci{constructor(t,e,s){super(s),this.A=new ot(t),this.T=new ot(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(os(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 ot(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 Si(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new ot(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(ns(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 Ti=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 ot(e)),t)),[new ot(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],s,t))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 wi(t,t,e).project()):!s||0!==r&&r!==n.length-1?i.push(...new Si(t,o,a,e).project()):i.push(...new wi(t,0===r?a:o,e).project())})),i},Oi=t=>{const e={};return Object.keys(t).forEach((s=>{e[s]={},Object.keys(t[s]).forEach((r=>{e[s][r]=i({},t[s][r])}))})),e},ki=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">"),Di=t=>{const e=[];for(let s,i=0;i{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};var Pi=Object.freeze({__proto__:null,capitalize:function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"".concat(t.charAt(0).toUpperCase()).concat(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:ki,graphemeSplit:Di});const Ei=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.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||s&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},Ai=(t,e)=>{const s=e.split("\n"),i=[];let r=-1,n={};t=Oi(t);for(let e=0;e0&&(Ei(n,o,!0)?i.push({start:r,end:r+1,style:o}):i[i.length-1].end++),n=o||{}}else r+=o.length,n={}}return i},ji=(t,e)=>{if(!Array.isArray(t))return Oi(t);const s=e.split(F),r={};let n=-1,o=0;for(let e=0;e{var e;return null!==(e=He[t])&&void 0!==e?e:t},Bi=new RegExp("(".concat(Ve,")"),"gi"),Xi=t=>t.replace(Bi," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var Yi,Wi,Vi,Gi,zi,Hi,Ni;const Ui="(".concat(Ve,")"),qi=String.raw(Yi||(Yi=n(["(skewX)(",")"],["(skewX)\\(","\\)"])),Ui),Ki=String.raw(Wi||(Wi=n(["(skewY)(",")"],["(skewY)\\(","\\)"])),Ui),Ji=String.raw(Vi||(Vi=n(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Ui,Ui,Ui),Qi=String.raw(Gi||(Gi=n(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Ui,Ui),Zi=String.raw(zi||(zi=n(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Ui,Ui),$i=String.raw(Hi||(Hi=n(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Ui,Ui,Ui,Ui,Ui,Ui),tr="(?:".concat($i,"|").concat(Zi,"|").concat(Ji,"|").concat(Qi,"|").concat(qi,"|").concat(Ki,")"),er="(?:".concat(tr,"*)"),sr=String.raw(Ni||(Ni=n(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),er),ir=new RegExp(sr),rr=new RegExp(tr),nr=new RegExp(tr,"g");function or(t){const e=[];if(!(t=Xi(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!ir.test(t))return[...T];for(const s of t.matchAll(nr)){const t=rr.exec(s[0]);if(!t)continue;let i=T;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=Dt(a,h);break;case B:i=Mt({angle:a},{x:h,y:c});break;case z:i=Pt(a,h);break;case U:i=At(a);break;case q:i=jt(a);break;case"matrix":i=[a,h,c,l,u,d]}e.push(i)}return Tt(e)}function ar(t,e,s,i){const r=Array.isArray(e);let n,o=e;if(t!==K&&t!==J||e!==j){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===j?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=s&&s.transformMatrix?wt(s.transformMatrix,or(e)):or(e);else if("visible"===t)o=e!==j&&"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?M:"end"===e?A:D;else if("charSpacing"===t)n=Kt(e,i)/i*1e3;else if("paintFirst"===t){const t=e.indexOf(K),s=e.indexOf(J);o=K,(t>-1&&s>-1&&s-1)&&(o=J)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=r?e.map(Kt):Kt(e,i)}}else o="";return!r&&isNaN(n)?o:n}function hr(t,e){const s=t.match(ze);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=Kt(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}function cr(t,e){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[s,i]=t.split(":");e[s.trim().toLowerCase()]=i.trim()}))}function lr(t){const e={},s=t.getAttribute("style");return s?("string"==typeof s?cr(s,e):function(t,e){Object.entries(t).forEach((t=>{let[s,i]=t;void 0!==i&&(e[s.toLowerCase()]=i)}))}(s,e),e):e}const ur={stroke:"strokeOpacity",fill:"fillOpacity"};function dr(t,e,s){if(!t)return{};let r,n={},o=O;t.parentNode&&Je.test(t.parentNode.nodeName)&&(n=dr(t.parentElement,e,s),n.fontSize&&(r=o=Kt(n.fontSize)));const a=i(i(i({},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 r in e)Ri(t,r.split(" "))&&(s=i(i({},s),e[r]));return s}(t,s)),lr(t));a[Ue]&&t.setAttribute(Ue,a[Ue]),a[Ne]&&(r=Kt(a[Ne],o),a[Ne]="".concat(r));const h={};for(const t in a){const e=Ii(t),s=ar(e,a[t],n,r);h[e]=s}h&&h.font&&hr(h.font,h);const c=i(i({},n),h);return Je.test(t.nodeName)?c:function(t){const e=_i.getDefaults();return Object.entries(ur).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 Ut(t[i]);t[i]=n.setAlpha(qt(n.getAlpha()*t[r],2)).toRgba()})),t}(c)}const gr=["left","top","width","height","visible"],fr=["rx","ry"];class pr extends _i{static getDefaults(){return i(i({},super.getDefaults()),pr.ownDefaults)}constructor(t){super(),Object.assign(this,pr.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-k*n,r,i+e,r+k*o,i+e,r+o),t.lineTo(i+e,r+s-o),a&&t.bezierCurveTo(i+e,r+s-k*o,i+e-k*n,r+s,i+e-n,r+s),t.lineTo(i+n,r+s),a&&t.bezierCurveTo(i+k*n,r+s,i,r+s-k*o,i,r+s-o),t.lineTo(i,r+o),a&&t.bezierCurveTo(i,r+k*o,i+k*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([...fr,...t])}_toSVG(){const{width:t,height:e,rx:s,ry:i}=this;return["\n')]}static async fromElement(t,e,s){const n=dr(t,this.ATTRIBUTE_NAMES,s),{left:o=0,top:a=0,width:h=0,height:c=0,visible:l=!0}=n,u=r(n,gr);return new this(i(i(i({},e),u),{},{left:o,top:a,width:h,height:c,visible:Boolean(l&&h&&c)}))}}e(pr,"type","Rect"),e(pr,"cacheProperties",[...ps,...fr]),e(pr,"ownDefaults",{rx:0,ry:0}),e(pr,"ATTRIBUTE_NAMES",[...Fi,"x","y","rx","ry","width","height"]),tt.setClass(pr),tt.setSVGClass(pr);const mr="initialization",vr="added",yr="removed",_r="imperative",xr=(t,e)=>{const{strokeUniform:s,strokeWidth:i,width:r,height:n,group:o}=e,a=o&&o!==t?we(o.calcTransformMatrix(),t.calcTransformMatrix()):null,h=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),l=s&&c?Oe(new ot(i,i),void 0,t.calcTransformMatrix()):at,u=!s&&c?i:0,d=Se(r+u,n+u,Tt([a,e.calcOwnMatrix()],!0)).add(l).scalarDivide(2);return[h.subtract(d),h.add(d)]};class Cr{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===mr||e===_r||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==mr&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===_r&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:n,width:o,height:a}=ve(t.map((t=>xr(i,t))).reduce(((t,e)=>t.concat(e)),[])),h=new ot(o,a),c=new ot(r,n).add(h.scalarDivide(2));if(s===mr){const t=this.getInitialSize(e,{size:h,center:c});return{center:c,relativeCorrection:new ot(0,0),size:t}}return{center:c.transform(i.calcOwnMatrix()),size:h}}}e(Cr,"type","strategy");class br extends Cr{shouldPerformLayout(t){return!0}}e(br,"type","fit-content"),tt.setClass(br);const Sr=["strategy"],wr=["target","strategy","bubbles","prevStrategy"],Tr="layoutManager";class Or{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new br;e(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=i(i({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[Q,L,Y,I,R,X,G,W,V].map((e=>t.on(e,(t=>this.performLayout(e===Q?{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:n}=e;if(s===mr||s===vr?this.subscribeTargets(t):s===yr&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),n&&n.fire("object:layout:before",{target:e,context:t}),s===_r&&t.deep){const s=r(t,Sr);e.forEachObject((t=>t.layoutManager&&t.layoutManager.performLayout(i(i({},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===mr?new ot:e.getRelativeCenterPoint(),{center:o,correction:a=new ot,relativeCorrection:h=new ot}=r,c=n.subtract(o).add(a).transform(i===mr?T:St(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===mr)?s.set({left:null!==(n=t.x)&&void 0!==n?n:r.x+i.x*Pe(s.originX),top:null!==(o=t.y)&&void 0!==o?o:r.y+i.y*Pe(s.originY)}):(s.setPositionByOrigin(r,D,D),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:n,bubbles:o,prevStrategy:a}=t,h=r(t,wr),{canvas:c}=s;s.fire("layout:after",{context:t,result:e}),c&&c.fire("object:layout:after",{context:t,result:e,target:s});const l=s.parent;o&&null!=l&&l.layoutManager&&((h.path||(h.path=[])).push(s),l.layoutManager.performLayout(i(i({},h),{},{target:l}))),s.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((t=>t.forEach((t=>t())))),t.clear()}toObject(){return{type:Tr,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}tt.setClass(Or,Tr);const kr=["type","objects","layoutManager"];class Dr extends Or{performLayout(){}}class Mr extends(ct(_i)){static getDefaults(){return i(i({},super.getDefaults()),Mr.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),e(this,"_activeObjects",[]),e(this,"__objectSelectionTracker",void 0),e(this,"__objectSelectionDisposer",void 0),Object.assign(this,Mr.ownDefaults),this.setOptions(s),this.groupInit(t,s)}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 Or,this.layoutManager.performLayout({type:mr,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(h("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(h("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;s1?e-1:0),i=1;i{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&&xe(t,wt(St(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||(xe(t,wt(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=_i.prototype.shouldCache.call(this);if(t)for(let t=0;tt.setCoords()))}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(i({target:this,type:_r},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 i(i(i({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#")}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=pr.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=["\n"],s=this._createSVGBgRect(t);s&&e.push("\t\t",s);for(let s=0;s\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 s=0;s{let[e,s]=t;const r=new this(e,i(i(i({},a),s),{},{layoutManager:new Dr}));if(o){const t=tt.getClass(o.type),e=tt.getClass(o.strategy);r.layoutManager=new t(new e)}else r.layoutManager=new Or;return r.layoutManager.subscribeTargets({type:mr,target:r,targets:r.getObjects()}),r.setCoords(),r}))}}e(Mr,"type","Group"),e(Mr,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tt.setClass(Mr);const Pr=(t,e)=>Math.min(e.width/t.width,e.height/t.height),Er=(t,e)=>Math.max(e.width/t.width,e.height/t.height),Ar="\\s*,?\\s*",jr="".concat(Ar,"(").concat(Ve,")"),Fr="".concat(jr).concat(jr).concat(jr).concat(Ar,"([01])").concat(Ar,"([01])").concat(jr).concat(jr),Lr={m:"l",M:"L"},Rr=(t,e,s,i,r,n,o,a,h,c,l)=>{const u=rt(t),d=nt(t),g=rt(e),f=nt(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]},Ir=(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 Br(t,e,s,i,r,n,o,h){let c;if(a.cachesBoundsOfCurve&&(c=[...arguments].join(),_.boundsOfCurveCache[c]))return _.boundsOfCurveCache[c];const l=Math.sqrt,u=Math.abs,d=[],g=[[0,0],[0,0]];let f=6*t-12*s+6*r,p=-3*t+9*s-9*r+3*o,m=3*s-3*t;for(let t=0;t<2;++t){if(t>0&&(f=6*e-12*i+6*n,p=-3*e+9*i-9*n+3*h,m=3*i-3*e),u(p)<1e-12){if(u(f)<1e-12)continue;const t=-m/f;0{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*w,d=nt(u),g=rt(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 S=c*C*p/b,T=-c*b*f/C,O=g*S-d*T+.5*t,k=d*S+g*T+.5*e;let D=Ir(1,0,(f-S)/C,(p-T)/b),M=Ir((f-S)/C,(p-T)/b,(-f-S)/C,(-p-T)/b);0===n&&M>0?M-=2*l:1===n&&M<0&&(M+=2*l);const P=Math.ceil(Math.abs(M/l*2)),E=[],A=M/P,j=8/3*Math.sin(A/4)*Math.sin(A/4)/Math.sin(A/2);let F=D+A;for(let t=0;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;case"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":Xr(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},Wr=(t,e,s,i)=>Math.sqrt((s-t)**2+(i-e)**2),Vr=(t,e,s,i,r,n,o,a)=>h=>{const c=h**3,l=(t=>3*t**2*(1-t))(h),u=(t=>3*t*(1-t)**2)(h),d=(t=>(1-t)**3)(h);return new ot(o*c+r*l+s*u+t*d,a*c+n*l+i*u+e*d)},Gr=t=>t**2,zr=t=>2*t*(1-t),Hr=t=>(1-t)**2,Nr=(t,e,s,i,r,n,o,a)=>h=>{const c=Gr(h),l=zr(h),u=Hr(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)},Ur=(t,e,s,i,r,n)=>o=>{const a=Gr(o),h=zr(o),c=Hr(o);return new ot(r*a+s*h+t*c,n*a+i*h+e*c)},qr=(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)},Kr=(t,e,s)=>{let i=new ot(e,s),r=0;for(let e=1;e<=100;e+=1){const s=t(e/100);r+=Wr(i.x,i.y,s.x,s.y),i=s}return r},Jr=(t,e)=>{let s,r=0,n=0,o={x:t.x,y:t.y},a=i({},o),h=.01,c=0;const l=t.iterator,u=t.angleFinder;for(;n1e-4;)a=l(r),c=r,s=Wr(o.x,o.y,a.x,a.y),s+n>e?(r-=h,h/=2):(o=a,r+=h,n+=s);return i(i({},a),{},{angle:u(c)})},Qr=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=Wr(r,n,c[1],c[2]),r=c[1],n=c[2];break;case"C":e=Vr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s=t,s.iterator=e,s.angleFinder=Nr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s.length=Kr(e,r,n),r=c[5],n=c[6];break;case"Q":e=Ur(r,n,c[1],c[2],c[3],c[4]),s=t,s.iterator=e,s.angleFinder=qr(r,n,c[1],c[2],c[3],c[4]),s.length=Kr(e,r,n),r=c[3],n=c[4];break;case"Z":s=t,s.destX=o,s.destY=a,s.length=Wr(r,n,o,a),r=o,n=a}i+=s.length,h.push(s)}return h.push({length:i,x:r,y:n}),h},Zr=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qr(t),r=0;for(;e-s[r].length>0&&r{var e;const s=[],i=null!==(e=t.match($r))&&void 0!==e?e:[];for(const t of i){const e=t[0];if("z"===e||"Z"===e){s.push([e]);continue}const i=sn[e.toLowerCase()];let r=[];if("a"===e||"A"===e){tn.lastIndex=0;for(let e=null;e=tn.exec(t);)r.push(...e.slice(1))}else r=t.match(en)||[];for(let t=0;t0&&o?o:e;for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:0,s=new ot(t[0]),i=new ot(t[1]),r=1,n=0;const o=[],a=t.length,h=a>2;let c;for(h&&(r=t[2].xt[c-2].x?1:s.x===t[c-2].x?0:-1,n=s.y>t[c-2].y?1:s.y===t[c-2].y?0:-1),o.push(["L",s.x+r*e,s.y+n*e]),o},on=(t,e)=>t.map((t=>t.map(((t,s)=>0===s||void 0===e?t:qt(t,e))).join(" "))).join(" ");function an(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)})))}const hn=(t,e)=>Math.floor(Math.random()*(e-t+1))+t;function cn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e.onComplete||C,i=new(v().XMLHttpRequest),r=e.signal,n=function(){i.abort()},o=function(){r&&r.removeEventListener("abort",n),i.onerror=i.ontimeout=C};if(r&&r.aborted)throw new l("request");return r&&r.addEventListener("abort",n,{once:!0}),i.onreadystatechange=function(){4===i.readyState&&(o(),s(i),i.onreadystatechange=C)},i.onerror=i.ontimeout=o,i.open("get",t,!0),i.send(),i}const ln=(t,e)=>{let s=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){const{scaleX:e,scaleY:s,angle:i,skewX:r}=kt(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(H,e),t.set(N,s),t.angle=i,t.skewX=r,t.skewY=0}})(t),s=s.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,s.x+=e.offsetLeft,s.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(s,D,D)};var un=Object.freeze({__proto__:null,addTransformToObject:_e,animate:js,animateColor:Fs,applyTransformToObject:xe,calcAngleBetweenVectors:is,calcDimensionsMatrix:Ft,calcPlaneChangeMatrix:we,calcVectorRotation:rs,cancelAnimFrame:dt,capValue:gs,composeMatrix:Lt,copyCanvasElement:t=>{var e;const s=vt(t);return null===(e=s.getContext("2d"))||void 0===e||e.drawImage(t,0,0),s},cos:rt,createCanvasElement:pt,createImage:mt,createRotateMatrix:Mt,createScaleMatrix:Pt,createSkewXMatrix:At,createSkewYMatrix:jt,createTranslateMatrix:Dt,createVector:es,crossProduct:as,degreesToRadians:_t,dotProduct:hs,ease:bs,enlivenObjectEnlivables:Bt,enlivenObjects:It,findScaleToCover:Er,findScaleToFit:Pr,getBoundsOfCurve:Br,getOrthonormalVector:os,getPathSegmentsInfo:Qr,getPointOnPath:Zr,getPointer:fe,getRandomInt:hn,getRegularPolygonPath:(t,e)=>{const s=2*Math.PI/t;let i=-b;t%2==0&&(i+=s/2);const r=new Array(t+1);for(let n=0;n{const e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},getUnitVector:ns,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new Mr(t,e),hasStyleChanged:Ei,invertTransform:St,isBetweenVectors:cs,isIdentityMatrix:Ct,isTouchEvent:pe,isTransparent:xi,joinPath:on,loadImage:Rt,magnitude:ss,makeBoundingBoxFromPoints:ve,makePathSimpler:Yr,matrixToSVG:Qt,mergeClipPaths:(t,e)=>{var s;let i=t,r=e;i.inverted&&!r.inverted&&(i=e,r=t),ke(r,null===(s=r.group)||void 0===s?void 0:s.calcTransformMatrix(),i.calcTransformMatrix());const n=i.inverted&&r.inverted;return n&&(i.inverted=r.inverted=!1),new Mr([i],{clipPath:r,inverted:n})},multiplyTransformMatrices:wt,multiplyTransformMatrixArray:Tt,parsePath:rn,parsePreserveAspectRatioAttribute:Jt,parseUnit:Kt,pick:Xt,projectStrokeOnPoints:Ti,qrDecompose:kt,radiansToDegrees:xt,removeFromArray:it,removeTransformFromObject:(t,e)=>{const s=St(e),i=wt(s,t.calcOwnMatrix());xe(t,i)},removeTransformMatrixForSvgParsing:ln,request:cn,requestAnimFrame:ut,resetObjectTransform:Ce,rotatePoint:(t,e,s)=>t.rotate(s,e),rotateVector:ts,saveObjectTransform:be,sendObjectToPlane:ke,sendPointToPlane:Te,sendVectorToPlane:Oe,setStyle:an,sin:nt,sizeAfterTransform:Se,string:Pi,stylesFromArray:ji,stylesToArray:Ai,toDataURL:yt,toFixed:qt,transformPath:(t,e,s)=>(s&&(e=wt(e,[1,0,0,1,-s.x,-s.y])),t.map((t=>{const s=[...t];for(let i=1;i1&&void 0!==arguments[1]?arguments[1]:{};super(t),e(this,"upper",void 0),e(this,"container",void 0);const{el:r}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:s}),this.applyCanvasStyle(n,{allowTouchScrolling:s,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=pt();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=m().createElement("div");return t.setAttribute("data-fabric","wrapper"),an(t,{position:"relative"}),ce(t),t}applyCanvasStyle(t,e){const{styles:s,allowTouchScrolling:r}=e;an(t,i(i({},s),{},{"touch-action":r?"manipulation":j})),ce(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:s,ctx:i}=this.upper;ae(s,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),he(this.upper.el,t),he(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(),p().dispose(this.upper.el),delete this.upper,delete this.container}}class gn extends de{constructor(){super(...arguments),e(this,"targets",[]),e(this,"_hoveredTargets",[]),e(this,"_objectsToRender",void 0),e(this,"_currentTransform",null),e(this,"_groupSelector",null),e(this,"contextTopDirty",!1)}static getDefaults(){return i(i({},super.getDefaults()),gn.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 dn(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)}isTargetTransparent(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 xi(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===z||e===H||e===N||e===Y?i=this.centeredScaling||t.centeredScaling:e===B&&(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=A:["mr","tr","br"].includes(e)&&(s.x=M),["tl","mt","tr"].includes(e)?s.y=E:["bl","mb","br"].includes(e)&&(s.y=P),s):s}_setupCurrentTransform(t,e,s){var r;const n=e.group?Te(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},h=s&&a?null===(r=a.getActionHandler(t,e,a))||void 0===r?void 0:r.bind(a):Be,c=((t,e,s,i)=>{if(!e||!t)return"drag";const r=i.controls[e];return r.getActionName(s,r,i)})(s,o,t,e),l=t[this.centeredKey],u=this._shouldCenterTransform(e,c,l)?{x:D,y:D}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:h,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:_t(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:l,original:i(i({},be(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new ot(e,s).transform(this.viewportTransform),o=new ot(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,_i.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,pe(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=rt(o)*r,h=nt(o)*r,c=a+h,l=a-h;s=[new ot(t.x-l,t.y-c),new ot(e.x+c,e.y-l),new ot(i.x+l,i.y+c),new ot(n.x-c,n.y+l)]}return Ls.isPointInPolygon(e,s)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Te(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;if(!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(ht(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&&ht(s)&&s.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const s=t[e];if(!ht(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=fe(t),n=i.width||0,o=i.height||0;n&&o||(P in i&&E in i&&(o=Math.abs(i.top-i.bottom)),A in i&&M 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=Te(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const h=0===n||0===o?new ot(1,1):new ot(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=pt(),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 ie(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,ie(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),ie(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(Q,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ie(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&&ie(e)&&this._activeObject===e){const s=Xt(t,["angle","flipX","flipY",M,H,N,U,q,P]);return _e(t,e.calcOwnMatrix()),s}return{}}_setSVGObject(t,e,s){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,s),e.set(i)}}e(gn,"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,hoverCursor:"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 fn{constructor(t){e(this,"targets",[]),e(this,"__disposer",void 0);const s=()=>{const{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},i=t.upperCanvasEl;i.addEventListener("click",s),this.__disposer=()=>i.removeEventListener("click",s)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),it(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 pn=["target","oldTarget","fireCanvas","e"],mn={passive:!1},vn=(t,e)=>{const s=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:s,scenePoint:i,pointer:s,absolutePointer:i}},yn=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{}),e(this,"_isClick",void 0),e(this,"textEditingManager",new fn(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((t=>{this[t]=this[t].bind(this)})),this.addOrRemove(yn,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const s=this.upperCanvasEl,i=this._getEventPrefix();t(oe(s),"resize",this._onResize),t(s,i+"down",this._onMouseDown),t(s,"".concat(i,"move"),this._onMouseMove,mn),t(s,"".concat(i,"out"),this._onMouseOut),t(s,"".concat(i,"enter"),this._onMouseEnter),t(s,"wheel",this._onMouseWheel),t(s,"contextmenu",this._onContextMenu),t(s,"dblclick",this._onDoubleClick),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,mn)}removeListeners(){this.addOrRemove(_n,"remove");const t=this._getEventPrefix(),e=ne(this.upperCanvasEl);_n(e,"".concat(t,"up"),this._onMouseUp),_n(e,"touchend",this._onTouchEnd,mn),_n(e,"".concat(t,"move"),this._onMouseMove,mn),_n(e,"touchmove",this._onMouseMove,mn),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,s=i({e:t},vn(this,t));this.fire("mouse:out",i(i({},s),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",i({},s)),this._hoveredTargets.forEach((t=>{this.fire("mouse:out",i(i({},s),{},{target:t})),t&&t.fire("mouseout",i({},s))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",i({e:t},vn(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 yn(this.upperCanvasEl,"drag",this._onDragProgress)}me(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(),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!==j,s=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:s};_n(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){this.targets=[];return{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 s=0;s0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),s=ne(this.upperCanvasEl);_n(s,"touchend",this._onTouchEnd,mn),_n(s,"touchmove",this._onMouseMove,mn),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{yn(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=ne(this.upperCanvasEl);_n(t,"".concat(s,"up"),this._onMouseUp),_n(t,"".concat(s,"move"),this._onMouseMove,mn),yn(e,"".concat(s,"move"),this._onMouseMove,mn)}}_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");const 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),pe(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{s=t.hoverCursor||s})),this.setCursor(s)}handleMultiSelection(t,e){const s=this._activeObject,i=ie(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(tt.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 ot(e,s),o=n.add(new ot(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=tt.getClass("ActiveSelection");this.setActiveObject(new e(l,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const bn={x1:0,y1:0,x2:0,y2:0},Sn=i(i({},bn),{},{r1:0,r2:0}),wn=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,Tn=/^(\d+\.\d+)%|(\d+)%$/;function On(t){return t&&Tn.test(t)}function kn(t,e){const s="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(On(t)?100:1):NaN;return gs(0,wn(s,e),1)}const Dn=/\s*;\s*/,Mn=/\s*:\s*/;function Pn(t,e){let s,i;const r=t.getAttribute("style");if(r){const t=r.split(Dn);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,n]=t[e].split(Mn).map((t=>t.trim()));"stop-color"===r?s=n:"stop-opacity"===r&&(i=n)}}const n=new Ut(s||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:kn(t.getAttribute("offset"),0),color:n.toRgb(),opacity:wn(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*n.getAlpha()*e}}function En(t,e){const s=[],i=t.getElementsByTagName("stop"),r=kn(e,1);for(let t=i.length;t--;)s.push(Pn(i[t],r));return s}function An(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function jn(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function Fn(t,e){return t.getAttribute(e)}function Ln(t,e){return function(t,e){let s,{width:i,height:r,gradientUnits:n}=e;return Object.keys(t).reduce(((e,o)=>{const a=t[o];return"Infinity"===a?s=1:"-Infinity"===a?s=0:(s="string"==typeof a?parseFloat(a):a,"string"==typeof a&&On(a)&&(s*=.01,"pixels"===n&&("x1"!==o&&"x2"!==o&&"r2"!==o||(s*=i),"y1"!==o&&"y2"!==o||(s*=r)))),e[o]=s,e}),{})}("linear"===An(t)?function(t){return{x1:Fn(t,"x1")||0,y1:Fn(t,"y1")||0,x2:Fn(t,"x2")||"100%",y2:Fn(t,"y2")||0}}(t):function(t){return{x1:Fn(t,"fx")||Fn(t,"cx")||"50%",y1:Fn(t,"fy")||Fn(t,"cy")||"50%",r1:0,x2:Fn(t,"cx")||"50%",y2:Fn(t,"cy")||"50%",r2:Fn(t,"r")||"50%"}}(t),i(i({},e),{},{gradientUnits:jn(t)}))}class Rn{constructor(t){const{type:e="linear",gradientUnits:s="pixels",coords:r={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:h,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:s,coords:i(i({},"radial"===e?Sn:bn),r),colorStops:n,offsetX:o,offsetY:a,gradientTransform:h,id:c?"".concat(c,"_").concat(ft()):ft()})}addColorStop(t){for(const e in t){const s=new Ut(t[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this}toObject(t){return i(i({},Xt(this,t)),{},{type:this.type,coords:i({},this.coords),colorStops:this.colorStops.map((t=>i({},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=[],r=this.gradientTransform?this.gradientTransform.concat():T.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((t=>i({},t))).sort(((t,e)=>t.offset-e.offset));let a=-this.offsetX,h=-this.offsetY;var c;"objectBoundingBox"===n?(a/=t.width,h/=t.height):(a+=t.width/2,h+=t.height/2),(c=t)&&"function"==typeof c._renderPathCommands&&"percentage"!==this.gradientUnits&&(a-=t.pathOffset.x,h-=t.pathOffset.y),r[4]-=a,r[5]-=h;const l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Qt(r),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:i,y2:r}=this.coords;s.push("\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:i,y2:r,r1:n,r2:a}=this.coords,h=n>a;s.push("\n'),h&&(o.reverse(),o.forEach((t=>{t.offset=1-t.offset})));const c=Math.min(n,a);if(c>0){const t=c/Math.max(n,a);o.forEach((e=>{e.offset+=t*(1-e.offset)}))}}return o.forEach((t=>{let{color:e,offset:i,opacity:r}=t;s.push("\n')})),s.push("linear"===this.type?"":"","\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 Ut(e).setAlpha(s).toRgba():e)})),a}static async fromObject(t){const{colorStops:e,gradientTransform:s}=t;return new this(i(i({},t),{},{colorStops:e?e.map((t=>i({},t))):void 0,gradientTransform:s?[...s]:void 0}))}static fromElement(t,e,s){const r=jn(t),n=e._findCenterFromElement();return new this(i({id:t.getAttribute("id")||void 0,type:An(t),coords:Ln(t,{width:s.viewBoxWidth||s.width,height:s.viewBoxHeight||s.height}),colorStops:En(t,s.opacity),gradientUnits:r,gradientTransform:or(t.getAttribute("gradientTransform")||"")},"pixels"===r?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}e(Rn,"type","Gradient"),tt.setClass(Rn,"gradient"),tt.setClass(Rn,"linear"),tt.setClass(Rn,"radial");const In=["type","source","patternTransform"];class Bn{get type(){return"pattern"}set type(t){h("warn","Setting type has no effect",t)}constructor(t){e(this,"repeat","repeat"),e(this,"offsetX",0),e(this,"offsetY",0),e(this,"crossOrigin",""),this.id=ft(),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 i(i({},Xt(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:s,offsetX:qt(this.offsetX,a.NUM_FRACTION_DIGITS),offsetY:qt(this.offsetY,a.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=wn(this.offsetX/e,0),a=wn(this.offsetY/s,0),h="repeat-y"===r||"no-repeat"===r?1+Math.abs(o||0):wn(i.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):wn(i.height/s,0);return[''),''),"",""].join("\n")}static async fromObject(t,e){let{type:s,source:n,patternTransform:o}=t,a=r(t,In);const h=await Rt(n,i(i({},e),{},{crossOrigin:a.crossOrigin}));return new this(i(i({},a),{},{patternTransform:o&&o.slice(0),source:h}))}}e(Bn,"type","Pattern"),tt.setClass(Bn),tt.setClass(Bn,"pattern");class Xn{constructor(t){e(this,"color","rgb(0, 0, 0)"),e(this,"width",1),e(this,"shadow",null),e(this,"strokeLineCap","round"),e(this,"strokeLineJoin","round"),e(this,"strokeMiterLimit",10),e(this,"strokeDashArray",null),e(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new Ut(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,s=t.contextTop,i=t.getZoom()*t.getRetinaScaling();s.shadowColor=e.color,s.shadowBlur=e.blur*i,s.shadowOffsetX=e.offsetX*i,s.shadowOffsetY=e.offsetY*i}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}const Yn=["path","left","top"],Wn=["d"];class Vn extends _i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:s,left:i,top:n}=e,o=r(e,Yn);super(),Object.assign(this,Vn.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),"number"==typeof i&&this.set(M,i),"number"==typeof n&&this.set(P,n)}_setPath(t,e){this.path=Yr(Array.isArray(t)?t:rn(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new ot(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"#")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return i(i({},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=on(this.path,a.NUM_FRACTION_DIGITS);return["\n')]}_getOffsetTransform(){const t=a.NUM_FRACTION_DIGITS;return" translate(".concat(qt(-this.pathOffset.x,t),", ").concat(qt(-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,D,D)}_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(...Br(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(...Br(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 ve(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return i(i({},t),{},{pathOffset:new ot(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 n=dr(t,this.ATTRIBUTE_NAMES,s),{d:o}=n;return new this(o,i(i(i({},r(n,Wn)),e),{},{left:void 0,top:void 0}))}}e(Vn,"type","Path"),e(Vn,"cacheProperties",[...ps,"path","fillRule"]),e(Vn,"ATTRIBUTE_NAMES",[...Fi,"d"]),tt.setClass(Vn),tt.setSVGClass(Vn);class Gn extends Xn{constructor(t){super(t),e(this,"decimate",.4),e(this,"drawStraightLine",!1),e(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,s){const i=e.midPointFrom(s);return t.quadraticCurveTo(e.x,e.y,i.x,i.y),i}onMouseDown(t,e){let{e:s}=e;this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:s}=e;if(this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const t=this._points,e=t.length,s=this.canvas.contextTop;this._saveAndTransform(s),this.oldEnd&&(s.beginPath(),s.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=Gn.drawSegment(s,t[e-2],t[e-1]),s.stroke(),s.restore()}}onMouseUp(t){let{e:e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvas.contextTop,e=this._points[0],s=this._points[1];if(this._saveAndTransform(t),t.beginPath(),2===this._points.length&&e.x===s.x&&e.y===s.y){const t=this.width/1e3;e.x-=t,s.x+=t}t.moveTo(e.x,e.y);for(let i=1;i=n&&(i=t[e],a.push(i));return a.push(t[o]),a}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(t){return"M 0 0 Q 0 0 0 0 L 0 0"===on(t)}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const zn=["left","top","radius"],Hn=["radius","startAngle","endAngle","counterClockwise"];class Nn extends _i{static getDefaults(){return i(i({},super.getDefaults()),Nn.ownDefaults)}constructor(t){super(),Object.assign(this,Nn.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,_t(this.startAngle),_t(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(H)}getRadiusY(){return this.get("radius")*this.get(N)}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([...Hn,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["\n'];{const{radius:e}=this,s=_t(this.startAngle),i=_t(this.endAngle),r=rt(s)*e,n=nt(s)*e,o=rt(i)*e,a=nt(i)*e,h=t>180?1:0,c=this.counterClockwise?0:1;return['\n"]}}static async fromElement(t,e,s){const n=dr(t,this.ATTRIBUTE_NAMES,s),{left:o=0,top:a=0,radius:h=0}=n;return new this(i(i({},r(n,zn)),{},{radius:h,left:o-h,top:a-h}))}static fromObject(t){return super._fromObject(t)}}e(Nn,"type","Circle"),e(Nn,"cacheProperties",[...ps,...Hn]),e(Nn,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),e(Nn,"ATTRIBUTE_NAMES",["cx","cy","r",...Fi]),tt.setClass(Nn),tt.setSVGClass(Nn);const Un=["x1","y1","x2","y2"],qn=["x1","y1","x2","y2"],Kn=["x1","x2","y1","y2"];class Jn extends _i{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,Jn.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(M,n),"number"==typeof o&&this.set(P,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}=ve([{x:t,y:e},{x:s,y:i}]),h=new ot(r+o/2,n+a/2);this.setPositionByOrigin(h,D,D)}_set(t,e){return super._set(t,e),Kn.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;$t(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 ot((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return i(i({},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["\n')]}static async fromElement(t,e,s){const i=dr(t,this.ATTRIBUTE_NAMES,s),{x1:n=0,y1:o=0,x2:a=0,y2:h=0}=i;return new this([n,o,a,h],r(i,Un))}static fromObject(t){let{x1:e,y1:s,x2:n,y2:o}=t,a=r(t,qn);return this._fromObject(i(i({},a),{},{points:[e,s,n,o]}),{extraParam:"points"})}}e(Jn,"type","Line"),e(Jn,"cacheProperties",[...ps,...Kn]),e(Jn,"ATTRIBUTE_NAMES",Fi.concat(Kn)),tt.setClass(Jn),tt.setSVGClass(Jn);class Qn extends _i{static getDefaults(){return i(i({},super.getDefaults()),Qn.ownDefaults)}constructor(t){super(),Object.assign(this,Qn.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["']}}e(Qn,"type","Triangle"),e(Qn,"ownDefaults",{width:100,height:100}),tt.setClass(Qn),tt.setSVGClass(Qn);const Zn=["rx","ry"];class $n extends _i{static getDefaults(){return i(i({},super.getDefaults()),$n.ownDefaults)}constructor(t){super(),Object.assign(this,$n.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(H)}getRy(){return this.get("ry")*this.get(N)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...Zn,...t])}_toSVG(){return["\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,S,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,s){const i=dr(t,this.ATTRIBUTE_NAMES,s);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}function to(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),s=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),e(this,"strokeDiff",void 0),Object.assign(this,io.ownDefaults),this.setOptions(s),this.points=t;const{left:i,top:r}=s;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(M,i),"number"==typeof r&&this.set(P,r)}isOpen(){return!0}_projectStrokeOnPoints(t){return Ti(this.points,t,this.isOpen())}_calcDimensions(t){t=i({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 ot,strokeOffset:new ot,strokeDiff:new ot};const s=ve(e),r=Ft(i(i({},t),{},{scaleX:1,scaleY:1})),n=ve(this.points.map((t=>bt(t,r,!0)))),o=new ot(this.scaleX,this.scaleY);let a=s.left+s.width/2,h=s.top+s.height/2;return this.exactBoundingBox&&(a-=h*Math.tan(_t(this.skewX)),h-=a*Math.tan(_t(this.skewY))),i(i({},s),{},{pathOffset:new ot(a,h),strokeOffset:new ot(n.left,n.top).subtract(new ot(s.left,s.top)).multiply(o),strokeDiff:new ot(s.width,s.height).subtract(new ot(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=ve(this.points);return new ot(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 ot(e+i/2,s+r/2),D,D)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new ot(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 ot(null!==(e=t.width)&&void 0!==e?e:i,null!==(s=t.height)&&void 0!==s?s:r)}else{var i,r;n=new ot(null!==(i=t.width)&&void 0!==i?i:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return n.multiply(new ot(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===H||t===N)&&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 i(i({},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=a.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r\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;rvoid 0!==t));this._setStyleDeclaration(s,r,n)}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 i(i({},Xt(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]}}e(mo,"_styleProperties",co);const vo=/ +/g,yo=/"/g;function _o(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]:a.NUM_FRACTION_DIGITS;const h=Zt(K,t,!1),[c,l,u,d]=[s,i,r,n].map((t=>qt(t,o)));return"')}(t,{left:e,top:s,width:i,height:r}),"\n")}const xo=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let Co;class bo extends mo{static getDefaults(){return i(i({},super.getDefaults()),bo.ownDefaults)}constructor(t,s){super(),e(this,"__charBounds",[]),Object.assign(this,bo.ownDefaults),this.setOptions(s),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=Qr(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(uo)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,s,i,r,n,o;for(let a=0,h=this._textLines.length;a')}_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===J?(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 D:t.textBaseline="middle";break;case"ascender":t.textBaseline=P;break;case"descender":t.textBaseline=E}t.font=this._getFontDeclaration(e,s)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,s=this._textLines.length;et&&(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 e=0,r=this._textLines.length;e=0:ie?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=Zr(i.path,s,i.segmentsInfo);e.renderLeft=r.x-i.pathOffset.x,e.renderTop=r.y-i.pathOffset.y,e.angle=r.angle+(this.pathSide===A?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}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let s=1,i=this._textLines[t].length;s0){let e=i+u+f;"rtl"===this.direction&&(e=this.width-e-p),m&&v&&(t.fillStyle=v,t.fillRect(e,y+o*_+x,p,this.fontSize/15)),f=n.left,p=n.width,m=d,v=g,_=h,x=c}else p+=n.kernedWidth}let C=i+u+f;"rtl"===this.direction&&(C=this.width-C-p),t.fillStyle=g,d&&g&&t.fillRect(C,y+o*_+x,p-n,this.fontSize/15),s+=h}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 Di(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),s=new Array(e.length),i=["\n"];let r=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return i(i({},super.toObject([...ho,...t])),{},{styles:Ai(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 e in t)"path"===e&&this.setPathInfo(),i=i||s.includes(e),r=r||"path"===e;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 n=dr(t,bo.ATTRIBUTE_NAMES,s),o=i(i({},e),n),{textAnchor:a=M,textDecoration:h="",dx:c=0,dy:l=0,top:u=0,left:d=0,fontSize:g=O,strokeWidth:f=1}=o,p=r(o,xo),m=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),i({left:d+c,top:u+l,underline:h.includes("underline"),overline:h.includes("overline"),linethrough:h.includes("line-through"),strokeWidth:0,fontSize:g},p)),v=m.getScaledHeight()/m.height,y=((m.height+m.strokeWidth)*m.lineHeight-m.height)*v,_=m.getScaledHeight()+y;let x=0;return a===D&&(x=m.getScaledWidth()/2),a===A&&(x=m.getScaledWidth()),m.set({left:m.left-x,top:m.top-(_-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:f}),m}static fromObject(t){return this._fromObject(i(i({},t),{},{styles:ji(t.styles||{},t.text)}),{extraParam:"text"})}}e(bo,"textLayoutProperties",ao),e(bo,"cacheProperties",[...ps,...ho]),e(bo,"ownDefaults",lo),e(bo,"type","Text"),e(bo,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),e(bo,"ATTRIBUTE_NAMES",Fi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),yi(bo,[class extends Xe{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})}_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",s.join(""),"\n"]}_getSVGTextAndBg(t,e){const s=[],i=[];let r,n=t;this.backgroundColor&&i.push(..._o(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t").concat(ki(t),"")}_setSVGTextLineText(t,e,s,i){const r=this.getHeightOfLine(e),n=this.textAlign.includes(uo),o=this._textLines[e];let a,h,c,l,u,d="",g=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let r=0,f=o.length-1;r<=f;r++)u=r===f||this.charSpacing,d+=o[r],c=this.__charBounds[e][r],0===g?(s+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[r])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(e,r),h=this.getCompleteStyleDeclaration(e,r+1),u=Ei(a,h,!0)),u&&(l=this._getStyleDeclaration(e,r),t.push(this._createTextCharSpan(d,l,s,i)),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;lt[e.replace("-","")])).join(" ")}}]),tt.setClass(bo),tt.setSVGClass(bo);class So{constructor(t){e(this,"target",void 0),e(this,"__mouseDownInPlace",!1),e(this,"__dragStartFired",!1),e(this,"__isDraggingOver",!1),e(this,"__dragStartSelection",void 0),e(this,"__dragImageDisposer",void 0),e(this,"_dispose",void 0),this.target=t;const s=[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=()=>{s.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{_.remove()},ne(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},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),n=i({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}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 es.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;if(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(G,{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)||j;o===j?(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(G,{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 wo=/[ \n\.,;!\?\-]/;class To extends bo{constructor(){super(...arguments),e(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 js({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}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-1;)e++,s--;return t-e}findLineBoundaryRight(t){let e=0,s=t;for(;!/\n/.test(this._text[s])&&s0&&this._reSpace.test(s[t])&&(-1===e||!F.test(s[t-1]))?t-1:t,r=s[i];for(;i>0&&ithis.__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()))}_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;if(t===e)return{selectionStart:i,selectionEnd:i};return{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 ot(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new ot(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(Q),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=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,r){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let h=!1;s||(s=1),this.shiftLineStyles(t,s);const c=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const s in this.styles[t]){const i=parseInt(s,10);i>=e&&(h=!0,n[i-e]=this.styles[t][s],a&&0===e||delete this.styles[t][s])}let l=!1;for(h&&!a&&(this.styles[t+s]=n,l=!0),(l||o>e)&&s--;s>0;)r&&r[s-1]?this.styles[t+s]={0:i({},r[s-1])}:c?this.styles[t+s]={0:i({},c)}:delete this.styles[t+s],s--;this._forceClearCache=!0}insertCharStyleObject(t,e,s,r){this.styles||(this.styles={});const n=this.styles[t],o=n?i({},n):{};s||(s=1);for(const t in o){const i=parseInt(t,10);i>=e&&(n[i+s]=o[i],o[i-s]||delete n[i])}if(this._forceClearCache=!0,r){for(;s--;)Object.keys(r[s]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+s]=i({},r[s]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&s--;)this.styles[t][e+s]=i({},a)}insertNewStyleBlock(t,e,s){const i=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let e=0;e0&&(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;n0?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=M:this._selectionDirection===A&&(this._selectionDirection=M,this.selectionEnd=t),this.selectionStart=s):s>t&&s{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,"; 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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const s=()=>{this.updateFromTextArea(),this.fire(G),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void s();const i=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,n=i.length,o=this.selectionStart,h=this.selectionEnd,c=o!==h;let l,u,d,g,f=n-r;const m=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),v=o>m.selectionStart;c?(u=this._text.slice(o,h),f+=h-o):nl[0]))),c?(d=o,g=h):v?(d=h-u.length,g=h):(d=h,g=h+u.length),this.removeStyleFromTo(d,g)),y.length){const{copyPasteData:t}=p();e&&y.join("")===t.copiedText&&!a.disableStyleCopyPaste&&(l=t.copiedTextStyle),this.insertNewStyleBlock(y,o,l)}s()}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}=p();t.copiedText=this.getSelectedText(),a.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;ae){r=!0;const t=n-i,s=n,h=Math.abs(t-e);o=Math.abs(s-e)=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===A);if(e.shiftKey?this.moveCursorWithShift(s):this.moveCursorWithoutShift(s),0!==s){const t=this.text.length;this.selectionStart=gs(0,this.selectionStart,t),this.selectionEnd=gs(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===M?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;if(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=M,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===A&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=M,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===M&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=A,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=A,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const ko=t=>!!t.button;class Do extends Oo{constructor(){super(...arguments),e(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new So(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),me(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e:e}=t;this.canvas&&this.editable&&!ko(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e:e}=t;this.canvas&&this.editable&&!ko(e)&&(this.selected=this===this.canvas._activeObject)}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||ko(e)||i||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}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(St(this.calcTransformMatrix())).add(new ot(-this._getLeftOffset(),-this._getTopOffset()));let s=0,i=0,r=0;for(let t=0;t0&&(i+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,a=this.__charBounds[r];for(let t=0;t0&&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)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_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 t=0;t0?s:0)};return"rtl"===this.direction&&(this.textAlign===A||this.textAlign===uo||this.textAlign===fo?a.left*=-1:this.textAlign===M||this.textAlign===go?a.left=n-(s>0?s:0):this.textAlign!==D&&this.textAlign!==po||(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(uo),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 e=h;e<=c;e++){const i=this._getLineLeftOffset(e)||0;let r=this.getHeightOfLine(e),o=0,a=0,d=0;if(e===h&&(a=this.__charBounds[h][l].left),e>=h&&e1)&&(r/=this.lineHeight);let g=s.left+i+a,f=r,p=0;const m=d-a;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",f=1,p=r):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===A||this.textAlign===uo||this.textAlign===fo?g=this.width-g-m:this.textAlign===M||this.textAlign===go?g=s.left+i-d:this.textAlign!==D&&this.textAlign!==po||(g=s.left+i-d)),t.fillRect(g,s.top+s.topOffset+p,m,f),s.topOffset+=o}}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,K)}_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()}}e(Lo,"ownDefaults",Fo),e(Lo,"type","IText"),tt.setClass(Lo),tt.setClass(Lo,"i-text");class Ro extends Lo{static getDefaults(){return i(i({},super.getDefaults()),Ro.ownDefaults)}constructor(t,e){super(t,i(i({},Ro.ownDefaults),e))}static createControls(){return{controls:mi()}}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(uo)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,s=0,i=0;const r={};for(let n=0;n0?(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 t in a)for(const i in a[t]){const n=parseInt(i,10);if(n>=s&&(!r||n{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;n3&&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;vp&&!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 t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}e(Ro,"type","Textbox"),e(Ro,"textLayoutProperties",[...Lo.textLayoutProperties,"width"]),e(Ro,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tt.setClass(Ro);class Io extends Cr{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}=ve(xr(s,i)),a=new ot(n,o);if(i.absolutePositioned){return{center:Te(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 ot,correction:i=new ot}=this.calcBoundingBox(e,t)||{};return{center:s.add(r),correction:i.subtract(r),size:a}}return{center:s.getRelativeCenterPoint().add(r),size:a}}}}e(Io,"type","clip-path"),tt.setClass(Io);class Bo extends Cr{getInitialSize(t,e){let{target:s}=t,{size:i}=e;return new ot(s.width||i.x,s.height||i.y)}}e(Bo,"type","fixed"),tt.setClass(Bo);class Xo extends Or{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 Yo extends Mr{static getDefaults(){return i(i({},super.getDefaults()),Yo.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,Yo.ownDefaults),this.setOptions(e);const{left:s,top:i,layoutManager:r}=e;this.groupInit(t,{left:s,top:i,layoutManager:null!=r?r:new Xo})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),s=0;s{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)))?(h("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)})),t===yr?s.forEach((t=>{t._onAfterObjectsChange(vr,e)})):s.forEach((t=>{t._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,s){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const r=i(i({hasControls:!1},s),{},{forActiveSelection:!0});for(let e=0;e{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 Vo{constructor(){let{tileSize:t=a.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),e(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=vt({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.originalWidth||0,originalHeight:e.height||e.originalHeight||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 Go;function zo(){const{WebGLProbe:t}=p();return t.queryWebGL(pt()),a.enableGLFiltering&&t.isSupported(a.textureSize)?new Vo({tileSize:a.textureSize}):new Wo}function Ho(){return!Go&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(Go=zo()),Go}const No=["filters","resizeFilter","src","crossOrigin","type"],Uo=["cropX","cropY"];class qo extends _i{static getDefaults(){return i(i({},super.getDefaults()),qo.ownDefaults)}constructor(t,s){super(),e(this,"_lastScaleX",1),e(this,"_lastScaleY",1),e(this,"_filterScalingX",1),e(this,"_filterScalingY",1),this.filters=[],Object.assign(this,qo.ownDefaults),this.setOptions(s),this.cacheKey="texture".concat(ft()),this.setElement("string"==typeof t?(this.canvas&&ne(this.canvas.getElement())||m()).getElementById(t):t,s)}getElement(){return this._element}setElement(t){let e=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(e),t.classList.add(qo.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Ho(!1);e instanceof Vo&&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&&p().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())})),i(i({},super.toObject([...Uo,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width\n','\t\n',"\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,n=['\t\n')],this.fill=t}return r=this.paintFirst!==K?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 Rt(t,{crossOrigin:e,signal:s}).then((t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)}))}toString(){return'#')}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=vt(n),{width:a,height:h}=n;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=r,Ho().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=vt({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);Ho().applyFilters(t,this._originalElement,s,i,this._element),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.naturalWidth||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=Jt(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===j&&t.alignY===j?(a=e/n,h=s/o):("meet"===t.meetOrSlice&&(a=h=Pr(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=Er(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:n,src:o,crossOrigin:a,type:h}=t,c=r(t,No);return Promise.all([Rt(o,i(i({},e),{},{crossOrigin:a})),s&&It(s,e),n&&It([n],e),Bt(c,e)]).then((t=>{let[e,s=[],[r]=[],n={}]=t;return new this(e,i(i({},c),{},{src:o,filters:s,resizeFilter:r},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 Rt(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=dr(t,this.ATTRIBUTE_NAMES,s);return this.fromURL(i["xlink:href"],e,i).catch((t=>(h("log","Unable to parse Image",t),null)))}}function Ko(t){if(!Ke.test(t.nodeName))return{};const e=t.getAttribute("viewBox");let s,i,r=1,n=1,o=0,a=0;const h=t.getAttribute("width"),c=t.getAttribute("height"),l=t.getAttribute("x")||0,u=t.getAttribute("y")||0,d=!(e&&Qe.test(e)),g=!h||!c||"100%"===h||"100%"===c;let f="",p=0,m=0;if(d&&(l||u)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") ",s=(t.getAttribute("transform")||"")+f,t.setAttribute("transform",s),t.removeAttribute("x"),t.removeAttribute("y")),d&&g)return{width:0,height:0};const v={width:0,height:0};if(d)return v.width=Kt(h),v.height=Kt(c),v;const y=e.match(Qe);o=-parseFloat(y[1]),a=-parseFloat(y[2]);const _=parseFloat(y[3]),x=parseFloat(y[4]);v.minX=o,v.minY=a,v.viewBoxWidth=_,v.viewBoxHeight=x,g?(v.width=_,v.height=x):(v.width=Kt(h),v.height=Kt(c),r=v.width/_,n=v.height/x);const C=Jt(t.getAttribute("preserveAspectRatio")||"");if(C.alignX!==j&&("meet"===C.meetOrSlice&&(n=r=r>n?n:r),"slice"===C.meetOrSlice&&(n=r=r>n?r:n),p=v.width-_*r,m=v.height-x*r,"Mid"===C.alignX&&(p/=2),"Mid"===C.alignY&&(m/=2),"Min"===C.alignX&&(p=0),"Min"===C.alignY&&(m=0)),1===r&&1===n&&0===o&&0===a&&0===l&&0===u)return v;if((l||u)&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") "),s=f+" matrix("+r+" 0 0 "+n+" "+(o*r+p)+" "+(a*n+m)+") ","svg"===t.nodeName){for(i=t.ownerDocument.createElementNS(Ge,"g");t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i)}else i=t,i.removeAttribute("x"),i.removeAttribute("y"),s=i.getAttribute("transform")+s;return i.setAttribute("transform",s),v}e(qo,"type","Image"),e(qo,"cacheProperties",[...ps,...Uo]),e(qo,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),e(qo,"CSS_CANVAS","canvas-img"),e(qo,"ATTRIBUTE_NAMES",[...Fi,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),tt.setClass(qo),tt.setSVGClass(qo);const Jo=t=>t.tagName.replace("svg:",""),Qo=Ye(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);function Zo(t,e){let s,i,r,n,o=[];for(r=0,n=e.length;r{const s=r.getAttribute(t);!e.hasAttribute(t)&&s&&e.setAttribute(t,s)})),!e.children.length)){const t=r.cloneNode(!0);for(;t.firstChild;)e.appendChild(t.firstChild)}e.removeAttribute(ta)}const sa=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"];function ia(t){const e=t.getElementsByTagName("style");let s,r;const n={};for(s=0,r=e.length;ss.length>1&&t.trim())).forEach((t=>{if((t.match(/{/g)||[]).length>1&&t.trim().startsWith("@"))return;const e=t.split("{"),o={},a=e[1].trim().split(";").filter((function(t){return t.trim()}));for(s=0,r=a.length;s{""!==(t=t.replace(/^svg/i,"").trim())&&(n[t]=i(i({},n[t]||{}),o))}))}))}return n}const ra=t=>tt.getSVGClass(Jo(t).toLowerCase());class na{constructor(t,e,s,i,r){this.elements=t,this.options=e,this.reviver=s,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=i,this.clipPaths=r,this.gradientDefs=function(t){const e=Zo(t,sa),s={};let i=e.length;for(;i--;){const r=e[i];r.getAttribute("xlink:href")&&ea(t,r);const n=r.getAttribute("id");n&&(s[n]=r)}return s}(i),this.cssRules=ia(i)}parse(){return Promise.all(this.elements.map((t=>this.createObject(t))))}async createObject(t){const e=ra(t);if(e){const s=await e.fromElement(t,this.options,this.cssRules);return this.resolveGradient(s,t,K),this.resolveGradient(s,t,J),s instanceof qo&&s._originalElement?ln(s,s.parsePreserveAspectRatioAttribute()):ln(s),await this.resolveClipPath(s,t),this.reviver&&this.reviver(t,s),s}return null}extractPropertyDefinition(t,e,s){const i=t[e],r=this.regexUrl;if(!r.test(i))return;r.lastIndex=0;const n=r.exec(i)[1];return r.lastIndex=0,s[n]}resolveGradient(t,e,s){const r=this.extractPropertyDefinition(t,s,this.gradientDefs);if(r){const n=e.getAttribute(s+"-opacity"),o=Rn.fromElement(r,t,i(i({},this.options),{},{opacity:n}));t.set(s,o)}}async resolveClipPath(t,e,s){const i=this.extractPropertyDefinition(t,"clipPath",this.clipPaths);if(i){const r=St(t.calcTransformMatrix()),n=i[0].parentElement;let o=e;for(;!s&&o.parentElement&&o.getAttribute("clip-path")!==t.clipPath;)o=o.parentElement;o.parentElement.appendChild(n);const a=or("".concat(o.getAttribute("transform")||""," ").concat(n.getAttribute("originalTransform")||""));n.setAttribute("transform","matrix(".concat(a.join(","),")"));const h=await Promise.all(i.map((t=>ra(t).fromElement(t,this.options,this.cssRules).then((t=>(ln(t),t.fillRule=t.clipRule,delete t.clipRule,t)))))),c=1===h.length?h[0]:new Mr(h),l=wt(r,c.calcTransformMatrix());c.clipPath&&await this.resolveClipPath(c,o,n.getAttribute("clip-path")?o:void 0);const{scaleX:u,scaleY:d,angle:g,skewX:f,translateX:p,translateY:m}=kt(l);c.set({flipX:!1,flipY:!1}),c.set({scaleX:u,scaleY:d,angle:g,skewX:f,skewY:0}),c.setPositionByOrigin(new ot(p,m),D,D),t.clipPath=c}else delete t.clipPath}}const oa=t=>qe.test(Jo(t)),aa=()=>({objects:[],elements:[],options:{},allElements:[]});async function ha(t,e){let{crossOrigin:s,signal:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r&&r.aborted)return h("log",new l("parseSVGDocument")),aa();const n=t.documentElement;!function(t){const e=Zo(t,["use","svg:use"]),s=["x","y","xlink:href","href","transform"];for(const i of e){const e=i.attributes,r={};for(const t of e)t.value&&(r[t.name]=t.value);const n=(r["xlink:href"]||r.href||"").slice(1);if(""===n)return;const o=t.getElementById(n);if(null===o)return;let a=o.cloneNode(!0);const h=a.attributes,c={};for(const t of h)t.value&&(c[t.name]=t.value);const{x:l=0,y:u=0,transform:d=""}=r,g="".concat(d," ").concat(c.transform||""," translate(").concat(l,", ").concat(u,")");if(Ko(a),/^svg$/i.test(a.nodeName)){const t=a.ownerDocument.createElementNS(Ge,"g");Object.entries(c).forEach((e=>{let[s,i]=e;return t.setAttributeNS(Ge,s,i)})),t.append(...a.childNodes),a=t}for(const t of e){if(!t)continue;const{name:e,value:i}=t;if(!s.includes(e))if("style"===e){const t={};cr(i,t),Object.entries(c).forEach((e=>{let[s,i]=e;t[s]=i})),cr(c.style||"",t);const s=Object.entries(t).map((t=>t.join(":"))).join(";");a.setAttribute(e,s)}else!c[e]&&a.setAttribute(e,i)}a.setAttribute("transform",g),a.setAttribute("instantiated_by_use","1"),a.removeAttribute("id"),i.parentNode.replaceChild(a,i)}}(t);const o=Array.from(n.getElementsByTagName("*")),a=i(i({},Ko(n)),{},{crossOrigin:s,signal:r}),c=o.filter((t=>(Ko(t),oa(t)&&!function(t){let e=t;for(;e&&(e=e.parentElement);)if(e&&e.nodeName&&Qo.test(Jo(e))&&!e.getAttribute("instantiated_by_use"))return!0;return!1}(t))));if(!c||c&&!c.length)return i(i({},aa()),{},{options:a,allElements:o});const u={};o.filter((t=>"clipPath"===Jo(t))).forEach((t=>{t.setAttribute("originalTransform",t.getAttribute("transform")||"");const e=t.getAttribute("id");u[e]=Array.from(t.getElementsByTagName("*")).filter((t=>oa(t)))}));const d=new na(c,a,e,t,u);return{objects:await d.parse(),elements:c,options:a,allElements:o}}const ca=W,la=t=>function(e,s,i){const{points:r,pathOffset:n}=i;return new ot(r[t]).subtract(n).transform(wt(i.getViewportTransform(),i.calcTransformMatrix()))},ua=(t,e,s,i)=>{const{target:r,pointIndex:n}=e,o=r,a=Te(new ot(s,i),void 0,o.calcOwnMatrix());return o.points[n]=a.add(o.pathOffset),o.setDimensions(),!0},da=(t,e)=>function(s,r,n,o){const a=r.target,h=new ot(a.points[(t>0?t:a.points.length)-1]),c=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()),l=e(s,i(i({},r),{},{pointIndex:t}),n,o),u=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()).subtract(c);return a.left-=u.x,a.top-=u.y,l},ga=t=>Ys(ca,da(t,ua));const fa=(t,e,s)=>{const{path:i,pathOffset:r}=t,n=i[e];return new ot(n[s]-r.x,n[s+1]-r.y).transform(wt(t.getViewportTransform(),t.calcTransformMatrix()))};function pa(t,e,s){const{commandIndex:i,pointIndex:r}=this;return fa(s,i,r)}function ma(t,e,s,r){const{target:n}=e,{commandIndex:o,pointIndex:a}=this,h=((t,e,s,i,r)=>{const{path:n,pathOffset:o}=t,a=n[(i>0?i:n.length)-1],h=new ot(a[r],a[r+1]),c=h.subtract(o).transform(t.calcOwnMatrix()),l=Te(new ot(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})(n,s,r,o,a);return De(this.actionName,i(i({},Le(t,e,s,r)),{},{commandIndex:o,pointIndex:a})),h}class va extends Hs{constructor(t){super(t)}render(t,e,s,r,n){const o=i(i({},r),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,s,o,n)}}class ya extends va{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=fa(r,h,c);if("Q"===l){const i=fa(r,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,s)}else t.moveTo(e,s);t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,s,i,r)}}const _a=(t,e,s,r,n,o)=>new(s?ya:va)(i(i({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:pa,actionHandler:ma,connectToCommandIndex:n,connectToPointIndex:o},r),s?r.controlPointStyle:r.pointStyle));var xa=Object.freeze({__proto__:null,changeWidth:Vs,createObjectDefaultControls:fi,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)]=_a(r,t.length-2,!1,e)),n){case"C":s["c_".concat(r,"_C_CP_1")]=_a(r,1,!0,e,r-1,(t=>"C"===t?5:"Q"===t?3:1)(i)),s["c_".concat(r,"_C_CP_2")]=_a(r,3,!0,e,r,5);break;case"Q":s["c_".concat(r,"_Q_CP_1")]=_a(r,1,!0,e,r,3)}i=n})),s},createPolyActionHandler:ga,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s={};for(let r=0;r<("number"==typeof t?t:t.points.length);r++)s["p".concat(r)]=new Hs(i({actionName:ca,positionHandler:la(r),actionHandler:ga(r)},e));return s},createPolyPositionHandler:la,createResizeControls:pi,createTextboxDefaultControls:mi,dragHandler:Be,factoryPolyActionHandler:da,getLocalPoint:Ie,polyActionHandler:ua,renderCircleControl:Gs,renderSquareControl:zs,rotationStyleHandler:Ns,rotationWithSnapping:Us,scaleCursorStyleHandler:Qs,scaleOrSkewActionName:li,scaleSkewCursorStyleHandler:ui,scalingEqually:$s,scalingX:ti,scalingXOrSkewingY:di,scalingY:ei,scalingYOrSkewingX:gi,skewCursorStyleHandler:ni,skewHandlerX:ai,skewHandlerY:hi,wrapWithFireEvent:Ys,wrapWithFixedAnchor:Ws});const Ca=t=>void 0!==t.webgl,ba="precision highp float",Sa="\n ".concat(ba,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),wa=["type"],Ta=["type"],Oa=new RegExp(ba,"g");class ka{get type(){return this.constructor.type}constructor(){let t=r(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},wa);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Sa}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"}}=p();"highp"!==i&&(e=e.replace(Oa,ba.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 c("Vertex, fragment shader or program creation error");if(t.shaderSource(r,s),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new c("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 c("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 c('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;r1){const s=t.destinationWidth,i=t.destinationHeight;t.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){Ca(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=vt({width:e,height:s});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return i({type:this.type},t.reduce(((t,e)=>(t[e]=this[e],t)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(r(t,Ta))}}e(ka,"type","BaseFilter"),e(ka,"uniformLocations",[]);const Da={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 Ma extends ka{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(Da[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t;const s=new Ut(this.color).getSource(),i=s[0]*this.alpha,r=s[1]*this.alpha,n=s[2]*this.alpha,o=1-this.alpha;for(let t=0;tnew this(i(i({},o),{},{image:t}))))}}e(Aa,"type","BlendImage"),e(Aa,"defaults",{mode:"multiply",alpha:1}),e(Aa,"uniformLocations",["uTransformMatrix","uImage"]),tt.setClass(Aa);class ja extends ka{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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n "}applyTo(t){Ca(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){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:s,filterBackend:{resources:i}}=t;const{width:r,height:n}=s;i.blurLayer1||(i.blurLayer1=pt(),i.blurLayer2=pt());const o=i.blurLayer1,a=i.blurLayer2;o.width===r&&o.height===n||(a.width=o.width=r,a.height=o.height=n);const h=o.getContext("2d"),c=a.getContext("2d"),l=15,u=.06*this.blur*.5;let d,g,f,p;for(h.putImageData(s,0,0),c.clearRect(0,0,r,n),p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*r+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,f,d),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);for(p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*n+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,d,f),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);e.drawImage(o,0,0);const m=e.getImageData(0,0,o.width,o.height);return h.globalAlpha=1,h.clearRect(0,0,o.width,o.height),m}sendUniformData(t,e){const s=this.chooseRightDelta();t.uniform2fv(e.uDelta,s)}isNeutralState(){return 0===this.blur}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const s=t*this.blur*.12;return this.horizontal?e[0]=s:e[1]=s,e}}e(ja,"type","Blur"),e(ja,"defaults",{blur:0}),e(ja,"uniformLocations",["uDelta"]),tt.setClass(ja);class Fa extends ka{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 t=0;t0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Ca(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((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=>tt.getClass(t.type).fromObject(t,e)))).then((t=>new this({subFilters:t})))}}e(za,"type","Composed"),tt.setClass(za);class Ha extends ka{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 t=0;t=a||m<0||m>=o||(y=4*(v*o+m),_=i[S*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 i(i({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}e(Ua,"type","Convolute"),e(Ua,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),e(Ua,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tt.setClass(Ua);const qa="Gamma";class Ka extends ka{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 t=0;t<256;t++)o.r[t]=255*Math.pow(t/255,i),o.g[t]=255*Math.pow(t/255,r),o.b[t]=255*Math.pow(t/255,n);for(let t=0;tr[0]&&i>r[1]&&o>r[2]&&s"\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){Ca(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=pt());const m=u.sliceByTwo;(m.width<1.5*e||m.height=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),S+=C,w+=C*n[b],T+=C*n[b+1],O+=C*n[b+2],k+=C*n[b+3]))}b=4*(_*i+y),a[b]=w/S,a[b+1]=T/S,a[b+2]=O/S,a[b+3]=k/S}return++y1&&n<-1||(l=2*n*n*n-3*n*n+1,l>0&&(s=4*(t+i*e),v+=l*c[s+3],g+=l,c[s+3]<255&&(l=l*c[s+3]/250),f+=l*c[s],p+=l*c[s+1],m+=l*c[s+2],d+=l))}}u[r]=f/d,u[r+1]=p/d,u[r+2]=m/d,u[r+3]=v/g}return l}}e(ih,"type","Resize"),e(ih,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),e(ih,"uniformLocations",["uDelta","uTaps"]),tt.setClass(ih);class rh extends ka{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 t=0;t{const s=vt({width:t,height:e}),i=pt().getContext("webgl"),r={imageBuffer:new ArrayBuffer(t*e*4)},n={destinationWidth:t,destinationHeight:e,targetCanvas:s};let o;o=v().performance.now(),Vo.prototype.copyGLTo2D.call(r,i,n);const a=v().performance.now()-o;o=v().performance.now(),Vo.prototype.copyGLTo2DPutImageData.call(r,i,n);return a>v().performance.now()-o},t.isWebGLPipelineState=Ca,t.loadSVGFromString=function(t,e,s){return ha((new(v().DOMParser)).parseFromString(t.trim(),"text/xml"),e,s)},t.loadSVGFromURL=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((e,i)=>{cn(t.replace(/^\n\s*/,"").trim(),{onComplete:t=>{const s=t.responseXML;s&&e(s),i()},signal:s.signal})})).then((t=>ha(t,e,s))).catch((()=>aa()))},t.parseAttributes=dr,t.parseFontDeclaration=hr,t.parsePointsAttribute=to,t.parseSVGDocument=ha,t.parseStyleAttribute=lr,t.parseTransformAttribute=or,t.runningAnimations=et,t.setEnv=t=>{f=t},t.setFilterBackend=function(t){Go=t},t.util=un,t.version=x})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).fabric={})}(this,(function(t){"use strict";function e(t,e,s){return(e=function(t){var e=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||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function s(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 i(t){for(var i=1;i=0)continue;s[i]=t[i]}return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i=0||{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function n(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class o{constructor(){e(this,"browserShadowBlurConstant",1),e(this,"DPI",96),e(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),e(this,"perfLimitSizeTotal",2097152),e(this,"maxCacheSideLimit",4096),e(this,"minCacheSideLimit",256),e(this,"disableStyleCopyPaste",!1),e(this,"enableGLFiltering",!0),e(this,"textureSize",4096),e(this,"forceGLPutImageData",!1),e(this,"cachesBoundsOfCurve",!1),e(this,"fontPaths",{}),e(this,"NUM_FRACTION_DIGITS",4)}}const a=new class extends o{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=i(i({},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 o,s=(null==t?void 0:t.reduce(((t,s)=>(t[s]=e[s],t)),{}))||e;this.configure(s)}},h=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis.testPrecision(e,t))),e.getExtension("WEBGL_lose_context").loseContext(),h("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const g={};let f;const p=()=>f||(f={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new d,dispose(){},copyPasteData:g}),m=()=>p().document,v=()=>p().window,y=()=>{var t;return Math.max(null!==(t=a.devicePixelRatio)&&void 0!==t?t:v().devicePixelRatio,1)};const _=new class{constructor(){e(this,"charWidthsCache",{}),e(this,"boundsOfCurveCache",{})}getFontCache(t){let{fontFamily:e,fontStyle:s,fontWeight:i}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});const r=this.charWidthsCache[e],n="".concat(s.toLowerCase(),"_").concat((i+"").toLowerCase());return r[n]||(r[n]={}),r[n]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){const{perfLimitSizeTotal:e}=a,s=Math.sqrt(e*t);return[Math.floor(s),Math.floor(e/s)]}};const x="6.5.2";function C(){}const b=Math.PI/2,w=2*Math.PI,S=Math.PI/180,T=Object.freeze([1,0,0,1,0,0]),O=16,k=.4477152502,D="center",M="left",P="top",E="bottom",A="right",j="none",F=/\r?\n/,L="moving",R="scaling",I="rotating",B="rotate",X="skewing",Y="resizing",W="modifyPoly",V="modifyPath",G="changed",z="scale",H="scaleX",N="scaleY",U="skewX",q="skewY",K="fill",J="stroke",Q="modified",Z="json",$="svg";const tt=new class{constructor(){this[Z]=new Map,this[$]=new Map}has(t){return this[Z].has(t)}getClass(t){const e=this[Z].get(t);if(!e)throw new c("No class registered for ".concat(t));return e}setClass(t,e){e?this[Z].set(e,t):(this[Z].set(t.type,t),this[Z].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[$].get(t)}setSVGClass(t,e){this[$].set(null!=e?e:t.type.toLowerCase(),t)}};const et=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 st{constructor(){e(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!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 t in this.__eventListeners)this._removeEventListener(t);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 t=0;t{const s=t.indexOf(e);return-1!==s&&t.splice(s,1),t},rt=t=>{if(0===t)return 1;switch(Math.abs(t)/b){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},nt=t=>{if(0===t)return 0;const e=t/b,s=Math.sign(t);switch(e){case 1:return s;case 2:return 0;case 3:return-s}return Math.sin(t)};class ot{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 ot(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new ot(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new ot(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new ot(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new ot(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new ot(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new ot(this.x/t.x,this.y/t.y)}scalarDivide(t){return new ot(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.xt.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 ot(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 ot(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new ot(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 ot(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at;const s=nt(t),i=rt(t),r=this.subtract(e);return new ot(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 ot(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 at=new ot(0,0),ht=t=>!!t&&Array.isArray(t._objects);function ct(t){class s extends t{constructor(){super(...arguments),e(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),s=0;sthis._onObjectAdded(t))),i}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis._onObjectAdded(t))),this._objects.length}remove(){const t=this._objects,e=[];for(var s=arguments.length,i=new Array(s),r=0;r{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;st.isType(...e)))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,e){return!!this._objects.includes(t)||!!e&&this._objects.some((e=>e instanceof s&&e.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])&&(it(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(it(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 it(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 it(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(it(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;s1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new ot(e,s),h=a.add(new ot(i,r));for(let t=this._objects.length-1;t>=0;t--){const e=this._objects[t];e.selectable&&e.visible&&(n&&e.intersectsWithRect(a,h)||e.isContainedWithinRect(a,h)||n&&e.containsPoint(a)||n&&e.containsPoint(h))&&o.push(e)}return o}}return s}class lt extends st{_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 ut(t){return v().requestAnimationFrame(t)}function dt(t){return v().cancelAnimationFrame(t)}let gt=0;const ft=()=>gt++,pt=()=>{const t=m().createElement("canvas");if(!t||void 0===t.getContext)throw new c("Failed to create `canvas` element");return t},mt=()=>m().createElement("img"),vt=t=>{const e=pt();return e.width=t.width,e.height=t.height,e},yt=(t,e,s)=>t.toDataURL("image/".concat(e),s),_t=t=>t*S,xt=t=>t/S,Ct=t=>t.every(((t,e)=>t===T[e])),bt=(t,e,s)=>new ot(t).transform(e,s),wt=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 ot(t[4],t[5]).transform(s,!0);return s[4]=-i,s[5]=-r,s},St=(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]],Tt=(t,e)=>t.reduceRight(((t,s)=>s&&t?St(s,t,e):s||t),void 0)||T.concat(),Ot=t=>{let[e,s]=t;return Math.atan2(s,e)},kt=t=>{const e=Ot(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:xt(e),scaleX:i,scaleY:r,skewX:xt(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},Dt=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Mt(){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=_t(t),r=rt(i),n=nt(i);return[r,n,-n,r,e?e-(r*e-n*s):0,s?s-(n*e+r*s):0]}const Pt=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Et=t=>Math.tan(_t(t)),At=t=>[1,0,Et(t),1,0,0],jt=t=>[1,Et(t),0,1,0,0],Ft=t=>{let{scaleX:e=1,scaleY:s=1,flipX:i=!1,flipY:r=!1,skewX:n=0,skewY:o=0}=t,a=Pt(i?-e:e,r?-s:s);return n&&(a=St(a,At(n),!0)),o&&(a=St(a,jt(o),!0)),a},Lt=t=>{const{translateX:e=0,translateY:s=0,angle:i=0}=t;let r=Dt(e,s);i&&(r=St(r,Mt({angle:i})));const n=Ft(t);return Ct(n)||(r=St(r,n)),r},Rt=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 l("loadImage"));const n=mt();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 c("Error loading ".concat(n.src)))},s&&(n.crossOrigin=s),n.src=t):a()}))},It=function(t){let{signal:e,reviver:s=C}=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=>tt.getClass(t.type).fromObject(t,{signal:e}).then((e=>(s(t,e),n.push(e),e)))))).then(i).catch((t=>{n.forEach((t=>{t.dispose&&t.dispose()})),r(t)})).finally((()=>{e&&e.removeEventListener("abort",r)}))}))},Bt=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&&tt.has(t.type)?It([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)}))}))},Xt=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce(((e,s)=>(s in t&&(e[s]=t[s]),e)),{})},Yt=(t,e)=>Object.keys(t).reduce(((s,i)=>(e(t[i],i,t)&&(s[i]=t[i]),s)),{}),Wt={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"},Vt=(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),Gt=(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+(e0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},Ht=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),Nt=t=>{let[e,s,i,r=1]=t;const n=Math.round(.3*e+.59*s+.11*i);return[n,n,n,r]};class Ut{constructor(t){if(e(this,"isUnrecognised",!1),t)if(t instanceof Ut)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 Wt&&(t=Wt[t]),"transparent"===t?[255,255,255,0]:Ut.sourceFromHex(t)||Ut.sourceFromRgb(t)||Ut.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=Gt(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=Gt(...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(Ht(t)).concat(Ht(e)).concat(Ht(s)).concat(Ht(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Nt(this.getSource())),this}toBlackWhite(t){const[e,,,s]=Nt(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof Ut||(t=new Ut(t));const e=this.getSource(),s=t.getSource(),[i,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 Ut.fromRgba(t)}static fromRgba(t){return new Ut(Ut.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[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,zt(e[4])]}}static fromHsl(t){return Ut.fromHsla(t)}static fromHsla(t){return new Ut(Ut.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const s=(Ut.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,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=Vt(e,t,s+1/3),o=Vt(e,t,s),a=Vt(e,t,s-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*a),zt(e[4])]}static fromHex(t){return new Ut(Ut.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map((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")?xt(s):e.includes("turn")?360*s:s}}const qt=(t,e)=>parseFloat(Number(t).toFixed(e)),Kt=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;const s=/\D{0,2}$/.exec(t),i=parseFloat(t),r=a.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}},Jt=t=>{const[e,s]=t.trim().split(" "),[i,r]=(n=e)&&n!==j?[n.slice(1,4),n.slice(5,8)]:n===j?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:s||"meet",alignX:i,alignY:r}},Qt=t=>"matrix("+t.map((t=>qt(t,a.NUM_FRACTION_DIGITS))).join(" ")+")",Zt=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 Ut(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,'" '):"")},$t=t=>!!t&&void 0!==t.toLive,te=t=>!!t&&"function"==typeof t.toObject,ee=t=>!!t&&void 0!==t.offsetX&&"source"in t,se=t=>!!t&&"multiSelectionStacking"in t;function ie(t){const e=t&&re(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 re=t=>t.ownerDocument||null,ne=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},oe=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))},ae=(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 he(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=j,t}class ce{constructor(t){e(this,"_originalCanvasStyle",void 0),e(this,"lower",void 0);const s=this.createLowerCanvas(t);this.lower={el:s,ctx:s.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&void 0!==s.getContext?t:t&&m().getElementById(t)||pt();var s;if(e.hasAttribute("data-fabric"))throw new c("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;oe(s,i,t,e)}setCSSDimensions(t){ae(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&re(t),i={left:0,top:0};if(!s)return i;const r=(null===(e=ne(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=ie(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(){p().dispose(this.lower.el),delete this.lower}}const le={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...T]};class ue extends(ct(lt)){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 ue.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}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new ce(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;i0&&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&&(h("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?y():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=i({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=bt(t,wt(i));i[0]=e,i[3]=e;const n=bt(r,i);i[4]+=s.x-n.x,i[5]+=s.y-n.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new ot(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 ot(-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=ut((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,s=wt(this.viewportTransform),i=bt({x:0,y:0},s),r=bt({x:t,y:e},s),n=i.min(r),o=i.max(r);return this.vptCoords={tl:n,tr:new ot(o.x,n.y),bl:new ot(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(dt(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const s=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const s=this.viewportTransform;t.save(),t.transform(...s),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let s=0,i=e.length;s!t.excludeFromExport)).map((s=>this._toObject(s,t,e)))},this.__serializeBgOverlay(t,e)),r?{clipPath:r}: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 $t(n)?n.excludeFromExport||(s.background=n.toObject(e)):n&&(s.background=n),$t(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('\n')),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push("\n"),this._setSVGBgOverlayColor(s,"overlay"),this._setSVGBgOverlayImage(s,"overlayImage",e),s.push(""),s.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('\n','\n')}_setSVGHeader(t,e){const s=e.width||"".concat(this.width),i=e.height||"".concat(this.height),r=a.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(qt(-t[4]/t[0],r)," ").concat(qt(-t[5]/t[3],r)," ").concat(qt(this.width/t[0],r)," ").concat(qt(this.height/t[3],r),'" ')}else o='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("\n',"Created with Fabric.js ",x,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(ft()),'\n').concat(e.toClipPathSVG(t.reviver),"\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if($t(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?Qt(i):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},s=a.fontPaths;this._objects.forEach((function e(s){t.push(s),ht(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\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($t(s)){const i=s.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?Qt(wt(this.viewportTransform)):"";t.push('\n'))}else t.push('\n")}loadFromJSON(t,e){let{signal:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new c("`json` is undefined"));const i="string"==typeof t?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:o,overlayImage:a,overlay:h,clipPath:l}=i,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([It(r,{reviver:e,signal:s}),Bt({backgroundImage:n,backgroundColor:o,overlayImage:a,overlayColor:h,clipPath:l},{signal:s})]).then((t=>{let[e,s]=t;return this.clear(),this.add(...e),this.set(i),this.set(s),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=vt(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 yt(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=vt({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}),et.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"#")}}e(ue,"ownDefaults",le);const de=["touchstart","touchmove","touchend"];const ge=t=>{const e=ie(t.target),s=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new ot(s.clientX+e.left,s.clientY+e.top)},fe=t=>de.includes(t.type)||"touch"===t.pointerType,pe=t=>{t.preventDefault(),t.stopPropagation()},me=t=>{let e=0,s=0,i=0,r=0;for(let n=0,o=t.length;ni||!n)&&(i=o),(or||!n)&&(r=a),(a_e(t,St(e,t.calcOwnMatrix())),_e=(t,e)=>{const s=kt(e),{translateX:i,translateY:n,scaleX:o,scaleY:a}=s,h=r(s,ve),c=new ot(i,n);t.flipX=!1,t.flipY=!1,Object.assign(t,h),t.set({scaleX:o,scaleY:a}),t.setPositionByOrigin(c,D,D)},xe=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},Ce=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}),be=(t,e,s)=>{const i=t/2,r=e/2,n=[new ot(-i,-r),new ot(i,-r),new ot(-i,r),new ot(i,r)].map((t=>t.transform(s))),o=me(n);return new ot(o.width,o.height)},we=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:T;return St(wt(arguments.length>1&&void 0!==arguments[1]?arguments[1]:T),t)},Se=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(we(e,s))},Te=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(we(e,s),!0)},Oe=(t,e,s)=>{const i=we(e,s);return _e(t,St(i,t.calcOwnMatrix())),i},ke=(t,e)=>{var s;const{transform:{target:r}}=e;null===(s=r.canvas)||void 0===s||s.fire("object:".concat(t),i(i({},e),{},{target:r})),r.fire(t,e)},De={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Me=t=>"string"==typeof t?De[t]:t-.5,Pe="not-allowed";function Ee(t){return Me(t.originX)===Me(D)&&Me(t.originY)===Me(D)}function Ae(t){return.5-Me(t)}const je=(t,e)=>t[e],Fe=(t,e,s,i)=>({e:t,transform:e,pointer:new ot(s,i)});function Le(t,e){const s=t.getTotalAngle()+xt(Math.atan2(e.y,e.x))+360;return Math.round(s%360/45)}function Re(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,D,D,s,i):new ot(t.left,t.top);return(t.angle?e.rotate(-_t(t.angle),r):e).subtract(n)}(o,new ot(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 Ie=(t,e,s,i)=>{const{target:r,offsetX:n,offsetY:o}=e,a=s-n,h=i-o,c=!je(r,"lockMovementX")&&r.left!==a,l=!je(r,"lockMovementY")&&r.top!==h;return c&&r.set(M,a),l&&r.set(P,h),(c||l)&&ke(L,Fe(t,e,s,i)),c||l};class Be{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",s=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):j,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=Zt(K,this.fill);return[Zt(J,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(Qt(s));return"".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(ft()),p='\n').concat(a.toClipPathSVG(s),"\n")),c&&g.push("\n"),g.push("\n");const m=[n,h,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,$t(u)&&g.push(u.toSVG(this)),$t(l)&&g.push(l.toSVG(this)),d&&g.push(d.toSVG(this)),a&&g.push(p),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==K?' paint-order="'.concat(this.paintFirst,'" '):""}}function Xe(t){return new RegExp("^("+t.join("|")+")\\b","i")}var Ye;const We=String.raw(Ye||(Ye=n(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Ve="http://www.w3.org/2000/svg",Ge=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+We+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+We+"))?\\s+(.*)"),ze={cx:M,x:M,r:"radius",cy:P,y:P,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"},He="font-size",Ne="clip-path",Ue=Xe(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),qe=Xe(["symbol","image","marker","pattern","view","svg"]),Ke=Xe(["symbol","g","a","svg","clipPath","defs"]),Je=new RegExp("^\\s*("+We+"+)\\s*,?\\s*("+We+"+)\\s*,?\\s*("+We+"+)\\s*,?\\s*("+We+"+)\\s*$"),Qe=new ot(1,0),Ze=new ot,$e=(t,e)=>t.rotate(e),ts=(t,e)=>new ot(e).subtract(t),es=t=>t.distanceFrom(Ze),ss=(t,e)=>Math.atan2(os(t,e),as(t,e)),is=t=>ss(Qe,t),rs=t=>t.eq(Ze)?t:t.scalarDivide(es(t)),ns=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rs(new ot(-t.y,t.x).scalarMultiply(e?1:-1))},os=(t,e)=>t.x*e.y-t.y*e.x,as=(t,e)=>t.x*e.x+t.y*e.y,hs=(t,e,s)=>{if(t.eq(e)||t.eq(s))return!0;const i=os(e,s),r=os(e,t),n=os(s,t);return i>=0?r>=0&&n<=0:!(r<=0&&n>=0)},cs="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",ls=new RegExp("(?:\\s|^)"+cs+cs+"("+We+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class us{constructor(t){const e="string"==typeof t?us.parseShadow(t):t;Object.assign(this,us.ownDefaults,e),this.id=ft()}static parseShadow(t){const e=t.trim(),[,s=0,i=0,r=0]=(ls.exec(e)||[]).map((t=>parseFloat(t)||0));return{color:(e.replace(ls,"")||"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=$e(new ot(this.offsetX,this.offsetY),_t(-t.angle)),s=new Ut(this.color);let i=40,r=40;return t.width&&t.height&&(i=100*qt((Math.abs(e.x)+this.blur)/t.width,a.NUM_FRACTION_DIGITS)+20,r=100*qt((Math.abs(e.y)+this.blur)/t.height,a.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\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=us.ownDefaults;return this.includeDefaultValues?t:Yt(t,((t,s)=>t!==e[s]))}static async fromObject(t){return new this(t)}}e(us,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),e(us,"type","shadow"),tt.setClass(us,"shadow");const ds=(t,e,s)=>Math.max(t,Math.min(e,s)),gs=[P,M,H,N,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",U,q],fs=[K,J,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ps={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:M,originY:P,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:K,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},ms=(t,e,s,i)=>(tt*Math.pow(2,10*(i-=1))*Math.sin((i*r-e)*w/s),ys=(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,_s=(t,e,s,i)=>(t/=i)<1/2.75?s*(7.5625*t*t)+e:t<2/2.75?s*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?s*(7.5625*(t-=2.25/2.75)*t+.9375)+e:s*(7.5625*(t-=2.625/2.75)*t+.984375)+e,xs=(t,e,s,i)=>s-_s(i-t,0,s,i)+e;var Cs=Object.freeze({__proto__:null,defaultEasing:ys,easeInBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*(t/=i)*t*((r+1)*t-r)+e},easeInBounce:xs,easeInCirc:(t,e,s,i)=>-s*(Math.sqrt(1-(t/=i)*t)-1)+e,easeInCubic:(t,e,s,i)=>s*(t/i)**3+e,easeInElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h}=ms(r,s,n,1.70158);return-vs(o,a,h,t,i)+e},easeInExpo:(t,e,s,i)=>0===t?e:s*2**(10*(t/i-1))+e,easeInOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return(t/=i/2)<1?s/2*(t*t*((1+(r*=1.525))*t-r))+e:s/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInOutBounce:(t,e,s,i)=>t(t/=i/2)<1?-s/2*(Math.sqrt(1-t**2)-1)+e:s/2*(Math.sqrt(1-(t-=2)*t)+1)+e,easeInOutCubic:(t,e,s,i)=>(t/=i/2)<1?s/2*t**3+e:s/2*((t-2)**3+2)+e,easeInOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(2===(t/=i/2))return e+s;n||(n=i*(.3*1.5));const{a:o,s:a,p:h,c:c}=ms(r,s,n,1.70158);return t<1?-.5*vs(o,a,h,t,i)+e:o*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*w/h)*.5+c+e},easeInOutExpo:(t,e,s,i)=>0===t?e:t===i?e+s:(t/=i/2)<1?s/2*2**(10*(t-1))+e:s/2*-(2**(-10*--t)+2)+e,easeInOutQuad:(t,e,s,i)=>(t/=i/2)<1?s/2*t**2+e:-s/2*(--t*(t-2)-1)+e,easeInOutQuart:(t,e,s,i)=>(t/=i/2)<1?s/2*t**4+e:-s/2*((t-=2)*t**3-2)+e,easeInOutQuint:(t,e,s,i)=>(t/=i/2)<1?s/2*t**5+e:s/2*((t-2)**5+2)+e,easeInOutSine:(t,e,s,i)=>-s/2*(Math.cos(Math.PI*t/i)-1)+e,easeInQuad:(t,e,s,i)=>s*(t/=i)*t+e,easeInQuart:(t,e,s,i)=>s*(t/=i)*t**3+e,easeInQuint:(t,e,s,i)=>s*(t/i)**5+e,easeInSine:(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,easeOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*((t=t/i-1)*t*((r+1)*t+r)+1)+e},easeOutBounce:_s,easeOutCirc:(t,e,s,i)=>s*Math.sqrt(1-(t=t/i-1)*t)+e,easeOutCubic:(t,e,s,i)=>s*((t/i-1)**3+1)+e,easeOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h,c:c}=ms(r,s,n,1.70158);return o*2**(-10*t)*Math.sin((t*i-a)*w/h)+c+e},easeOutExpo:(t,e,s,i)=>t===i?e+s:s*-(2**(-10*t/i)+1)+e,easeOutQuad:(t,e,s,i)=>-s*(t/=i)*(t-2)+e,easeOutQuart:(t,e,s,i)=>-s*((t=t/i-1)*t**3-1)+e,easeOutQuint:(t,e,s,i)=>s*((t/i-1)**5+1)+e,easeOutSine:(t,e,s,i)=>s*Math.sin(t/i*b)+e});const bs=()=>!1;class ws{constructor(t){let{startValue:s,byValue:i,duration:r=500,delay:n=0,easing:o=ys,onStart:a=C,onChange:h=C,onComplete:c=C,abort:l=bs,target:u}=t;e(this,"_state","pending"),e(this,"durationProgress",0),e(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=n,this.easing=o,this._onStart=a,this._onChange=h,this._onComplete=c,this._abort=l,this.target=u,this.startValue=s,this.byValue=i,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((()=>ut(t)),this.delay):ut(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),ut(this.tick)))}register(){et.push(this)}unregister(){et.remove(this)}abort(){this._state="aborted",this.unregister()}}const Ss=["startValue","endValue"];class Ts extends ws{constructor(t){let{startValue:e=0,endValue:s=100}=t;super(i(i({},r(t,Ss)),{},{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 Os=["startValue","endValue"];class ks extends ws{constructor(t){let{startValue:e=[0],endValue:s=[100]}=t;super(i(i({},r(t,Os)),{},{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 Ds=["startValue","endValue","easing","onChange","onComplete","abort"],Ms=(t,e,s,i)=>e+s*(1-Math.cos(t/i*b)),Ps=t=>t&&((e,s,i)=>t(new Ut(e).toRgba(),s,i));class Es extends ws{constructor(t){let{startValue:e,endValue:s,easing:n=Ms,onChange:o,onComplete:a,abort:h}=t,c=r(t,Ds);const l=new Ut(e).getSource(),u=new Ut(s).getSource();super(i(i({},c),{},{startValue:l,byValue:u.map(((t,e)=>t-l[e])),easing:n,onChange:Ps(o),onComplete:Ps(a),abort:Ps(h)}))}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),ds(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 As(t){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(t)?new ks(t):new Ts(t);return e.start(),e}function js(t){const e=new Es(t);return e.start(),e}class Fs{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!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=ts(e,s),n=ts(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 ot(t).setX(Math.min(t.x-1,...e.map((t=>t.x))));let i=0;for(let r=0;r4&&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 Fs("Intersection").append(new ot(t.x+e*o,t.y+e*a)):new Fs}if(0===d||0===g){const o=r||n||Fs.isPointContained(t,s,i)||Fs.isPointContained(e,s,i)||Fs.isPointContained(s,t,e)||Fs.isPointContained(i,t,e);return new Fs(o?"Coincident":void 0)}return new Fs("Parallel")}static intersectSegmentLine(t,e,s,i){return Fs.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return Fs.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 Fs,n=s.length;for(let o,a,h,c=0;c0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,s){return Fs.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new Fs,i=t.length,r=[];for(let n=0;n0&&r.length===t.length?new Fs("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 ot(r.x,i.y),o=new ot(i.x,r.y);return Fs.intersectPolygonPolygon(t,[i,n,r,o])}}class Ls extends lt{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?bt(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=bt(t,wt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new ot(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=>bt(e,t)))}return r}intersectsWithRect(t,e){return"Intersection"===Fs.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Fs.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}=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 Fs.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;if(this.intersectsWithRect(t,e))return!0;return 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 me(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(H,t),this._set(N,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?xt(Ot(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||T.concat()}calcACoords(){const t=Mt({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=Dt(e,s),r=St(i,t),n=this._getTransformedDimensions(),o=n.x/2,a=n.y/2;return{tl:bt({x:-o,y:-a},r),tr:bt({x:o,y:-a},r),bl:bt({x:-o,y:a},r),br:bt({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,Me(this.originX),Me(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=St(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=Lt(i);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new ot(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=i({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 r=s,n=0;this.strokeUniform&&(r=0,n=s);const o=e.width+r,a=e.height+r;let h;return h=0===e.skewX&&0===e.skewY?new ot(o*e.scaleX,a*e.scaleY):be(o,a,Ft(e)),h.scalarAdd(n)}translateToGivenOrigin(t,e,s,i,r){let n=t.x,o=t.y;const a=Me(i)-Me(e),h=Me(r)-Me(s);if(a||h){const t=this._getTransformedDimensions();n+=a*t.x,o+=h*t.y}return new ot(n,o)}translateToCenterPoint(t,e,s){if(e===D&&s===D)return t;const i=this.translateToGivenOrigin(t,e,s,D,D);return this.angle?i.rotate(_t(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,D,D,e,s);return this.angle?i.rotate(_t(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?bt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new ot(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(),M,P)}}const Rs=["type"],Is=["extraParam"];let Bs=class t extends Ls{static getDefaults(){return t.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){h("warn","Setting type has no effect",t)}constructor(s){super(),e(this,"_cacheContext",null),Object.assign(this,t.ownDefaults),this.setOptions(s)}_createCacheCanvas(){this._cacheCanvas=pt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=a.maxCacheSideLimit,r=a.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=a.perfLimitSizeTotal)return ec&&(t.zoomX/=e/c,t.width=c,t.capped=!0),s>l&&(t.zoomY/=s/l,t.height=l,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;if(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 ot(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=kt(this.calcTransformMatrix());return new ot(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){t.transform(i)})),e.parentClipPaths.push(t),t.absolutePositioned){const t=wt(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()),!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,$t(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&&($t(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)||T,o=r*i,h=n*i,c=e.nonScaling?new ot(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*a.browserShadowBlurConstant*(o+h)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*o*c.x,t.shadowOffsetY=e.offsetY*h*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!$t(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===J?(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=vt({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 ot(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(tt.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Ce(this),s=this.group,i=this.shadow,r=Math.abs,n=t.enableRetinaScaling?y():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new ue(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&xe(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Oe(this,this.getViewportTransform()),this.setCoords();const h=pt(),c=this.getBoundingRect(),l=this.shadow,u=new ot;if(l){const t=l.blur,e=l.nonScaling?new ot(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 ot(f.width/2,f.height/2),D,D);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 yt(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;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 r=t.split("."),n=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:h,onComplete:c}=s,l=i(i({},s),{},{target:this,startValue:null!=a?a:r.reduce(((t,e)=>t[e]),this),endValue:e,abort:null==o?void 0:o.bind(this),onChange:(t,e,s)=>{r.reduce(((e,s,i)=>(i===r.length-1&&(e[s]=t),e[s])),this),h&&h(t,e,s)},onComplete:(t,e,s)=>{this.setCoords(),c&&c(t,e,s)}});return n?js(l):As(l)}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-1&&n>o}toObject(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(t.customProperties,this.constructor.customProperties||[]);let s;const r=a.NUM_FRACTION_DIGITS,{clipPath:n,fill:o,stroke:h,shadow:c,strokeDashArray:l,left:u,top:d,originX:g,originY:f,width:p,height:m,strokeWidth:v,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:w,scaleX:S,scaleY:T,angle:O,flipX:k,flipY:D,opacity:M,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:L,skewY:R}=this;n&&!n.excludeFromExport&&(s=n.toObject(e.concat("inverted","absolutePositioned")));const I=t=>qt(t,r),B=i(i({},Xt(this,e)),{},{type:this.constructor.type,version:x,originX:g,originY:f,left:I(u),top:I(d),width:I(p),height:I(m),fill:te(o)?o.toObject():o,stroke:te(h)?h.toObject():h,strokeWidth:I(v),strokeDashArray:l?l.concat():l,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:I(w),scaleX:I(S),scaleY:I(T),angle:I(O),flipX:k,flipY:D,opacity:I(M),shadow:c?c.toObject():c,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:I(L),skewY:I(R)},s?{clipPath:s}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Yt(t,((t,e)=>{if(e===M||e===P||"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=r(t,Rs),s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:i}=s,n=r(s,Is);return Bt(e,n).then((t=>i?(delete t[i],new this(e[i],t)):new this(t)))}static fromObject(t,e){return this._fromObject(t,e)}};e(Bs,"stateProperties",gs),e(Bs,"cacheProperties",fs),e(Bs,"ownDefaults",ps),e(Bs,"type","FabricObject"),e(Bs,"colorProperties",[K,J,"backgroundColor"]),e(Bs,"customProperties",[]),tt.setClass(Bs),tt.setClass(Bs,"object");const Xs=(t,e,s)=>(r,n,o,a)=>{const h=e(r,n,o,a);return h&&ke(t,i(i({},Fe(r,n,o,a)),s)),h};function Ys(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 Ws=Xs(Y,Ys(((t,e,s,i)=>{const r=Re(e,e.originX,e.originY,s,i);if(Me(e.originX)===Me(D)||Me(e.originX)===Me(A)&&r.x<0||Me(e.originX)===Me(M)&&r.x>0){const{target:t}=e,s=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=Ee(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 Vs(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?J:K,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,w,!1),t[h](),c&&t.stroke(),t.restore()}function Gs(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?J:K,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(_t(d)),t["".concat(h,"Rect")](-l,-u,n,o),c&&t.strokeRect(-l,-u,n,o),t.restore()}class zs{constructor(t){e(this,"visible",!0),e(this,"actionName",z),e(this,"angle",0),e(this,"x",0),e(this,"y",0),e(this,"offsetX",0),e(this,"offsetY",0),e(this,"sizeX",0),e(this,"sizeY",0),e(this,"touchSizeX",0),e(this,"touchSizeY",0),e(this,"cursorStyle","crosshair"),e(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)&&Fs.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}positionHandler(t,e,s,i){return new ot(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,r,n){const o=Tt([Dt(s,i),Mt({angle:t}),Pt((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new ot(-.5,-.5).transform(o),tr:new ot(.5,-.5).transform(o),br:new ot(.5,.5).transform(o),bl:new ot(-.5,.5).transform(o)}}render(t,e,s,i,r){if("circle"===((i=i||{}).cornerStyle||r.cornerStyle))Vs.call(this,t,e,s,i,r);else Gs.call(this,t,e,s,i,r)}}const Hs=(t,e,s)=>s.lockRotation?Pe:e.cursorStyle,Ns=Xs(I,Ys(((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(je(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=xt(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){const i=Us(t,s);if(qs(s,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return Pe;const r=Le(s,e);return"".concat(Ks[r],"-resize")};function Qs(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const n=e.target,o=r.by,a=Us(t,n);let h,c,l,u,d,g;if(qs(n,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,l=e.scaleY*e.gestureScale;else{if(h=Re(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),je(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);Ee(e)&&(c*=2,l*=2),e.signX!==d&&"y"!==o&&(e.originX=Ae(e.originX),c*=-1,e.signX=d),e.signY!==g&&"x"!==o&&(e.originY=Ae(e.originY),l*=-1,e.signY=g)}const f=n.scaleX,p=n.scaleY;return o?("x"===o&&n.set(H,c),"y"===o&&n.set(N,l)):(!je(n,"lockScalingX")&&n.set(H,c),!je(n,"lockScalingY")&&n.set(N,l)),f!==n.scaleX||p!==n.scaleY}const Zs=Xs(R,Ys(((t,e,s,i)=>Qs(t,e,s,i)))),$s=Xs(R,Ys(((t,e,s,i)=>Qs(t,e,s,i,{by:"x"})))),ti=Xs(R,Ys(((t,e,s,i)=>Qs(t,e,s,i,{by:"y"})))),ei=["target","ex","ey","skewingSide"],si={x:{counterAxis:"y",scale:H,skew:U,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:N,skew:q,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},ii=["ns","nesw","ew","nwse"],ri=(t,e,s)=>{if(0!==e.x&&je(s,"lockSkewingY"))return Pe;if(0!==e.y&&je(s,"lockSkewingX"))return Pe;const i=Le(s,e)%4;return"".concat(ii[i],"-resize")};function ni(t,e,s,n,o){const{target:a}=s,{counterAxis:h,origin:c,lockSkewing:l,skew:u,flip:d}=si[t];if(je(a,l))return!1;const{origin:g,flip:f}=si[h],p=Me(s[g])*(a[f]?-1:1),m=-Math.sign(p)*(a[d]?-1:1),v=.5*-((0===a[u]&&Re(s,D,D,n,o)[t]>0||a[u]>0?1:-1)*m)+.5,y=Xs(X,Ys(((e,s,i,n)=>function(t,e,s){let{target:i,ex:n,ey:o,skewingSide:a}=e,h=r(e,ei);const{skew:c}=si[t],l=s.subtract(new ot(n,o)).divide(new ot(i.scaleX,i.scaleY))[t],u=i[c],d=h[c],g=Math.tan(_t(d)),f="y"===t?i._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:i._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*l*a/Math.max(f,1)+g,m=xt(Math.atan(p));i.set(c,m);const v=u!==i[c];if(v&&"y"===t){const{skewX:t,scaleX:e}=i,s=i._getTransformedDimensions({skewY:u}),r=i._getTransformedDimensions(),n=0!==t?s.x/r.x:1;1!==n&&i.set(H,n*e)}return v}(t,s,new ot(i,n)))));return y(e,i(i({},s),{},{[c]:v,skewingSide:m}),n,o)}const oi=(t,e,s,i)=>ni("x",t,e,s,i),ai=(t,e,s,i)=>ni("y",t,e,s,i);function hi(t,e){return t[e.canvas.altActionKey]}const ci=(t,e,s)=>{const i=hi(t,s);return 0===e.x?i?U:N:0===e.y?i?q:H:""},li=(t,e,s)=>hi(t,s)?ri(0,e,s):Js(t,e,s),ui=(t,e,s,i)=>hi(t,e.target)?ai(t,e,s,i):$s(t,e,s,i),di=(t,e,s,i)=>hi(t,e.target)?oi(t,e,s,i):ti(t,e,s,i),gi=()=>({ml:new zs({x:-.5,y:0,cursorStyleHandler:li,actionHandler:ui,getActionName:ci}),mr:new zs({x:.5,y:0,cursorStyleHandler:li,actionHandler:ui,getActionName:ci}),mb:new zs({x:0,y:.5,cursorStyleHandler:li,actionHandler:di,getActionName:ci}),mt:new zs({x:0,y:-.5,cursorStyleHandler:li,actionHandler:di,getActionName:ci}),tl:new zs({x:-.5,y:-.5,cursorStyleHandler:Js,actionHandler:Zs}),tr:new zs({x:.5,y:-.5,cursorStyleHandler:Js,actionHandler:Zs}),bl:new zs({x:-.5,y:.5,cursorStyleHandler:Js,actionHandler:Zs}),br:new zs({x:.5,y:.5,cursorStyleHandler:Js,actionHandler:Zs}),mtr:new zs({x:0,y:-.5,actionHandler:Ns,cursorStyleHandler:Hs,offsetY:-40,withConnection:!0,actionName:B})}),fi=()=>({mr:new zs({x:.5,y:0,actionHandler:Ws,cursorStyleHandler:li,actionName:Y}),ml:new zs({x:-.5,y:0,actionHandler:Ws,cursorStyleHandler:li,actionName:Y})}),pi=()=>i(i({},gi()),fi());class mi extends Bs{static getDefaults(){return i(i({},super.getDefaults()),mi.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),mi.ownDefaults),this.setOptions(t)}static createControls(){return{controls:gi()}}_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(z))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=Dt(e.x,e.y),i=Mt({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=St(s,i),n=St(t,r),o=St(n,[1/t[0],0,0,1/t[3],0,0]),a=this.group?kt(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)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(_t(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 r=i({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},s);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:s,hasControls:r}=this,n=i({hasBorders:s,hasControls:r},e),o=this.getViewportTransform(),a=n.hasBorders,h=n.hasControls,c=St(o,this.calcTransformMatrix()),l=kt(c);t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(_t(this.group?l.angle:this.angle)),a&&this.drawBorders(t,l,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const t=be(this.width,this.height,Ft(e)),s=this.isStrokeAccountedForInDimensions()?at:(this.strokeUniform?(new ot).scalarAdd(this.canvas?this.canvas.getZoom():1):new ot(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:r,cornerDashArray:n,cornerColor:o}=this,a=i({cornerStrokeColor:r,cornerDashArray:n,cornerColor:o},e);t.setTransform(s,0,0,s,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((e,s)=>{if(e.getVisibility(this,s)){const i=this.oCoords[s];e.render(t,i.x,i.y,a,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 vi(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}e(mi,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class yi extends mi{}vi(yi,[Be]),tt.setClass(yi),tt.setClass(yi,"object");const _i=(t,e,s,i)=>{const r=2*(i=Math.round(i))+1,{data:n}=t.getImageData(e-i,s-i,r,r);for(let t=3;t0)return!1}return!0};class xi{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new ot(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new ot(1/this.options.scaleX,1/this.options.scaleY):new ot(1,1)}createSideVector(t,e){const s=ts(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 ot(t);return e.y+=e.x*Math.tan(_t(this.options.skewY)),e.x+=e.y*Math.tan(_t(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Ci=new ot;class bi extends xi{static getOrthogonalRotationFactor(t,e){const s=e?ss(t,e):is(t);return Math.abs(s)2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),r=ns(i),n=bi.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,s*n)}projectBevel(){const t=[];return(this.alpha%w==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?es(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return es(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new ot(bi.getOrthogonalRotationFactor(this.bisector),bi.getOrthogonalRotationFactor(new ot(this.bisector.y,this.bisector.x)));return[new ot(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new ot(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach((i=>{hs(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 ot(Math.tan(_t(i)),Math.tan(_t(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 ot(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 ot(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=>{hs(i,t,e)&&s.push(this.applySkew(this.A).add(i))})),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%w==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=os(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 wi extends xi{constructor(t,e,s){super(s),this.A=new ot(t),this.T=new ot(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(ns(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 ot(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 bi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new ot(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(rs(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 Si=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 ot(e)),t)),[new ot(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],s,t))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 wi(t,t,e).project()):!s||0!==r&&r!==n.length-1?i.push(...new bi(t,o,a,e).project()):i.push(...new wi(t,0===r?a:o,e).project())})),i},Ti=t=>{const e={};return Object.keys(t).forEach((s=>{e[s]={},Object.keys(t[s]).forEach((r=>{e[s][r]=i({},t[s][r])}))})),e},Oi=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">"),ki=t=>{const e=[];for(let s,i=0;i{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};var Mi=Object.freeze({__proto__:null,capitalize:function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"".concat(t.charAt(0).toUpperCase()).concat(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:Oi,graphemeSplit:ki});const Pi=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.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||s&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},Ei=(t,e)=>{const s=e.split("\n"),i=[];let r=-1,n={};t=Ti(t);for(let e=0;e0&&(Pi(n,o,!0)?i.push({start:r,end:r+1,style:o}):i[i.length-1].end++),n=o||{}}else r+=o.length,n={}}return i},Ai=(t,e)=>{if(!Array.isArray(t))return Ti(t);const s=e.split(F),r={};let n=-1,o=0;for(let e=0;e{var e;return null!==(e=ze[t])&&void 0!==e?e:t},Ii=new RegExp("(".concat(We,")"),"gi"),Bi=t=>t.replace(Ii," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var Xi,Yi,Wi,Vi,Gi,zi,Hi;const Ni="(".concat(We,")"),Ui=String.raw(Xi||(Xi=n(["(skewX)(",")"],["(skewX)\\(","\\)"])),Ni),qi=String.raw(Yi||(Yi=n(["(skewY)(",")"],["(skewY)\\(","\\)"])),Ni),Ki=String.raw(Wi||(Wi=n(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Ni,Ni,Ni),Ji=String.raw(Vi||(Vi=n(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Ni,Ni),Qi=String.raw(Gi||(Gi=n(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Ni,Ni),Zi=String.raw(zi||(zi=n(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Ni,Ni,Ni,Ni,Ni,Ni),$i="(?:".concat(Zi,"|").concat(Qi,"|").concat(Ki,"|").concat(Ji,"|").concat(Ui,"|").concat(qi,")"),tr="(?:".concat($i,"*)"),er=String.raw(Hi||(Hi=n(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),tr),sr=new RegExp(er),ir=new RegExp($i),rr=new RegExp($i,"g");function nr(t){const e=[];if(!(t=Bi(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!sr.test(t))return[...T];for(const s of t.matchAll(rr)){const t=ir.exec(s[0]);if(!t)continue;let i=T;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=Dt(a,h);break;case B:i=Mt({angle:a},{x:h,y:c});break;case z:i=Pt(a,h);break;case U:i=At(a);break;case q:i=jt(a);break;case"matrix":i=[a,h,c,l,u,d]}e.push(i)}return Tt(e)}function or(t,e,s,i){const r=Array.isArray(e);let n,o=e;if(t!==K&&t!==J||e!==j){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===j?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=s&&s.transformMatrix?St(s.transformMatrix,nr(e)):nr(e);else if("visible"===t)o=e!==j&&"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?M:"end"===e?A:D;else if("charSpacing"===t)n=Kt(e,i)/i*1e3;else if("paintFirst"===t){const t=e.indexOf(K),s=e.indexOf(J);o=K,(t>-1&&s>-1&&s-1)&&(o=J)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=r?e.map(Kt):Kt(e,i)}}else o="";return!r&&isNaN(n)?o:n}function ar(t,e){const s=t.match(Ge);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=Kt(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}function hr(t,e){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[s,i]=t.split(":");e[s.trim().toLowerCase()]=i.trim()}))}function cr(t){const e={},s=t.getAttribute("style");return s?("string"==typeof s?hr(s,e):function(t,e){Object.entries(t).forEach((t=>{let[s,i]=t;void 0!==i&&(e[s.toLowerCase()]=i)}))}(s,e),e):e}const lr={stroke:"strokeOpacity",fill:"fillOpacity"};function ur(t,e,s){if(!t)return{};let r,n={},o=O;t.parentNode&&Ke.test(t.parentNode.nodeName)&&(n=ur(t.parentElement,e,s),n.fontSize&&(r=o=Kt(n.fontSize)));const a=i(i(i({},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 r in e)Li(t,r.split(" "))&&(s=i(i({},s),e[r]));return s}(t,s)),cr(t));a[Ne]&&t.setAttribute(Ne,a[Ne]),a[He]&&(r=Kt(a[He],o),a[He]="".concat(r));const h={};for(const t in a){const e=Ri(t),s=or(e,a[t],n,r);h[e]=s}h&&h.font&&ar(h.font,h);const c=i(i({},n),h);return Ke.test(t.nodeName)?c:function(t){const e=yi.getDefaults();return Object.entries(lr).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 Ut(t[i]);t[i]=n.setAlpha(qt(n.getAlpha()*t[r],2)).toRgba()})),t}(c)}const dr=["left","top","width","height","visible"],gr=["rx","ry"];class fr extends yi{static getDefaults(){return i(i({},super.getDefaults()),fr.ownDefaults)}constructor(t){super(),Object.assign(this,fr.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-k*n,r,i+e,r+k*o,i+e,r+o),t.lineTo(i+e,r+s-o),a&&t.bezierCurveTo(i+e,r+s-k*o,i+e-k*n,r+s,i+e-n,r+s),t.lineTo(i+n,r+s),a&&t.bezierCurveTo(i+k*n,r+s,i,r+s-k*o,i,r+s-o),t.lineTo(i,r+o),a&&t.bezierCurveTo(i,r+k*o,i+k*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([...gr,...t])}_toSVG(){const{width:t,height:e,rx:s,ry:i}=this;return["\n')]}static async fromElement(t,e,s){const n=ur(t,this.ATTRIBUTE_NAMES,s),{left:o=0,top:a=0,width:h=0,height:c=0,visible:l=!0}=n,u=r(n,dr);return new this(i(i(i({},e),u),{},{left:o,top:a,width:h,height:c,visible:Boolean(l&&h&&c)}))}}e(fr,"type","Rect"),e(fr,"cacheProperties",[...fs,...gr]),e(fr,"ownDefaults",{rx:0,ry:0}),e(fr,"ATTRIBUTE_NAMES",[...ji,"x","y","rx","ry","width","height"]),tt.setClass(fr),tt.setSVGClass(fr);const pr="initialization",mr="added",vr="removed",yr="imperative",_r=(t,e)=>{const{strokeUniform:s,strokeWidth:i,width:r,height:n,group:o}=e,a=o&&o!==t?we(o.calcTransformMatrix(),t.calcTransformMatrix()):null,h=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),l=s&&c?Te(new ot(i,i),void 0,t.calcTransformMatrix()):at,u=!s&&c?i:0,d=be(r+u,n+u,Tt([a,e.calcOwnMatrix()],!0)).add(l).scalarDivide(2);return[h.subtract(d),h.add(d)]};class xr{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===pr||e===yr||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==pr&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===yr&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:n,width:o,height:a}=me(t.map((t=>_r(i,t))).reduce(((t,e)=>t.concat(e)),[])),h=new ot(o,a),c=new ot(r,n).add(h.scalarDivide(2));if(s===pr){const t=this.getInitialSize(e,{size:h,center:c});return{center:c,relativeCorrection:new ot(0,0),size:t}}return{center:c.transform(i.calcOwnMatrix()),size:h}}}e(xr,"type","strategy");class Cr extends xr{shouldPerformLayout(t){return!0}}e(Cr,"type","fit-content"),tt.setClass(Cr);const br=["strategy"],wr=["target","strategy","bubbles","prevStrategy"],Sr="layoutManager";class Tr{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Cr;e(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=i(i({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[Q,L,Y,I,R,X,G,W,V].map((e=>t.on(e,(t=>this.performLayout(e===Q?{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:n}=e;if(s===pr||s===mr?this.subscribeTargets(t):s===vr&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),n&&n.fire("object:layout:before",{target:e,context:t}),s===yr&&t.deep){const s=r(t,br);e.forEachObject((t=>t.layoutManager&&t.layoutManager.performLayout(i(i({},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===pr?new ot:e.getRelativeCenterPoint(),{center:o,correction:a=new ot,relativeCorrection:h=new ot}=r,c=n.subtract(o).add(a).transform(i===pr?T:wt(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===pr)?s.set({left:null!==(n=t.x)&&void 0!==n?n:r.x+i.x*Me(s.originX),top:null!==(o=t.y)&&void 0!==o?o:r.y+i.y*Me(s.originY)}):(s.setPositionByOrigin(r,D,D),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:n,bubbles:o,prevStrategy:a}=t,h=r(t,wr),{canvas:c}=s;s.fire("layout:after",{context:t,result:e}),c&&c.fire("object:layout:after",{context:t,result:e,target:s});const l=s.parent;o&&null!=l&&l.layoutManager&&((h.path||(h.path=[])).push(s),l.layoutManager.performLayout(i(i({},h),{},{target:l}))),s.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((t=>t.forEach((t=>t())))),t.clear()}toObject(){return{type:Sr,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}tt.setClass(Tr,Sr);const Or=["type","objects","layoutManager"];class kr extends Tr{performLayout(){}}class Dr extends(ct(yi)){static getDefaults(){return i(i({},super.getDefaults()),Dr.ownDefaults)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),e(this,"_activeObjects",[]),e(this,"__objectSelectionTracker",void 0),e(this,"__objectSelectionDisposer",void 0),Object.assign(this,Dr.ownDefaults),this.setOptions(s),this.groupInit(t,s)}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 Tr,this.layoutManager.performLayout({type:pr,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(h("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(h("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;s1?e-1:0),i=1;i{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&&_e(t,St(wt(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||(_e(t,St(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=yi.prototype.shouldCache.call(this);if(t)for(let t=0;tt.setCoords()))}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(i({target:this,type:yr},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 i(i(i({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#")}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=fr.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=["\n"],s=this._createSVGBgRect(t);s&&e.push("\t\t",s);for(let s=0;s\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 s=0;s{let[e,s]=t;const r=new this(e,i(i(i({},a),s),{},{layoutManager:new kr}));if(o){const t=tt.getClass(o.type),e=tt.getClass(o.strategy);r.layoutManager=new t(new e)}else r.layoutManager=new Tr;return r.layoutManager.subscribeTargets({type:pr,target:r,targets:r.getObjects()}),r.setCoords(),r}))}}e(Dr,"type","Group"),e(Dr,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tt.setClass(Dr);const Mr=(t,e)=>Math.min(e.width/t.width,e.height/t.height),Pr=(t,e)=>Math.max(e.width/t.width,e.height/t.height),Er="\\s*,?\\s*",Ar="".concat(Er,"(").concat(We,")"),jr="".concat(Ar).concat(Ar).concat(Ar).concat(Er,"([01])").concat(Er,"([01])").concat(Ar).concat(Ar),Fr={m:"l",M:"L"},Lr=(t,e,s,i,r,n,o,a,h,c,l)=>{const u=rt(t),d=nt(t),g=rt(e),f=nt(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]},Rr=(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 Ir(t,e,s,i,r,n,o,h){let c;if(a.cachesBoundsOfCurve&&(c=[...arguments].join(),_.boundsOfCurveCache[c]))return _.boundsOfCurveCache[c];const l=Math.sqrt,u=Math.abs,d=[],g=[[0,0],[0,0]];let f=6*t-12*s+6*r,p=-3*t+9*s-9*r+3*o,m=3*s-3*t;for(let t=0;t<2;++t){if(t>0&&(f=6*e-12*i+6*n,p=-3*e+9*i-9*n+3*h,m=3*i-3*e),u(p)<1e-12){if(u(f)<1e-12)continue;const t=-m/f;0{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*S,d=nt(u),g=rt(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,T=-c*b*f/C,O=g*w-d*T+.5*t,k=d*w+g*T+.5*e;let D=Rr(1,0,(f-w)/C,(p-T)/b),M=Rr((f-w)/C,(p-T)/b,(-f-w)/C,(-p-T)/b);0===n&&M>0?M-=2*l:1===n&&M<0&&(M+=2*l);const P=Math.ceil(Math.abs(M/l*2)),E=[],A=M/P,j=8/3*Math.sin(A/4)*Math.sin(A/4)/Math.sin(A/2);let F=D+A;for(let t=0;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;case"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":Br(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},Yr=(t,e,s,i)=>Math.sqrt((s-t)**2+(i-e)**2),Wr=(t,e,s,i,r,n,o,a)=>h=>{const c=h**3,l=(t=>3*t**2*(1-t))(h),u=(t=>3*t*(1-t)**2)(h),d=(t=>(1-t)**3)(h);return new ot(o*c+r*l+s*u+t*d,a*c+n*l+i*u+e*d)},Vr=t=>t**2,Gr=t=>2*t*(1-t),zr=t=>(1-t)**2,Hr=(t,e,s,i,r,n,o,a)=>h=>{const c=Vr(h),l=Gr(h),u=zr(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)},Nr=(t,e,s,i,r,n)=>o=>{const a=Vr(o),h=Gr(o),c=zr(o);return new ot(r*a+s*h+t*c,n*a+i*h+e*c)},Ur=(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)},qr=(t,e,s)=>{let i=new ot(e,s),r=0;for(let e=1;e<=100;e+=1){const s=t(e/100);r+=Yr(i.x,i.y,s.x,s.y),i=s}return r},Kr=(t,e)=>{let s,r=0,n=0,o={x:t.x,y:t.y},a=i({},o),h=.01,c=0;const l=t.iterator,u=t.angleFinder;for(;n1e-4;)a=l(r),c=r,s=Yr(o.x,o.y,a.x,a.y),s+n>e?(r-=h,h/=2):(o=a,r+=h,n+=s);return i(i({},a),{},{angle:u(c)})},Jr=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=Yr(r,n,c[1],c[2]),r=c[1],n=c[2];break;case"C":e=Wr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s=t,s.iterator=e,s.angleFinder=Hr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s.length=qr(e,r,n),r=c[5],n=c[6];break;case"Q":e=Nr(r,n,c[1],c[2],c[3],c[4]),s=t,s.iterator=e,s.angleFinder=Ur(r,n,c[1],c[2],c[3],c[4]),s.length=qr(e,r,n),r=c[3],n=c[4];break;case"Z":s=t,s.destX=o,s.destY=a,s.length=Yr(r,n,o,a),r=o,n=a}i+=s.length,h.push(s)}return h.push({length:i,x:r,y:n}),h},Qr=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jr(t),r=0;for(;e-s[r].length>0&&r{var e;const s=[],i=null!==(e=t.match(Zr))&&void 0!==e?e:[];for(const t of i){const e=t[0];if("z"===e||"Z"===e){s.push([e]);continue}const i=en[e.toLowerCase()];let r=[];if("a"===e||"A"===e){$r.lastIndex=0;for(let e=null;e=$r.exec(t);)r.push(...e.slice(1))}else r=t.match(tn)||[];for(let t=0;t0&&o?o:e;for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:0,s=new ot(t[0]),i=new ot(t[1]),r=1,n=0;const o=[],a=t.length,h=a>2;let c;for(h&&(r=t[2].xt[c-2].x?1:s.x===t[c-2].x?0:-1,n=s.y>t[c-2].y?1:s.y===t[c-2].y?0:-1),o.push(["L",s.x+r*e,s.y+n*e]),o},nn=(t,e)=>t.map((t=>t.map(((t,s)=>0===s||void 0===e?t:qt(t,e))).join(" "))).join(" ");function on(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)})))}const an=(t,e)=>Math.floor(Math.random()*(e-t+1))+t;function hn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e.onComplete||C,i=new(v().XMLHttpRequest),r=e.signal,n=function(){i.abort()},o=function(){r&&r.removeEventListener("abort",n),i.onerror=i.ontimeout=C};if(r&&r.aborted)throw new l("request");return r&&r.addEventListener("abort",n,{once:!0}),i.onreadystatechange=function(){4===i.readyState&&(o(),s(i),i.onreadystatechange=C)},i.onerror=i.ontimeout=o,i.open("get",t,!0),i.send(),i}const cn=(t,e)=>{let s=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){const{scaleX:e,scaleY:s,angle:i,skewX:r}=kt(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(H,e),t.set(N,s),t.angle=i,t.skewX=r,t.skewY=0}})(t),s=s.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,s.x+=e.offsetLeft,s.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(s,D,D)};var ln=Object.freeze({__proto__:null,addTransformToObject:ye,animate:As,animateColor:js,applyTransformToObject:_e,calcAngleBetweenVectors:ss,calcDimensionsMatrix:Ft,calcPlaneChangeMatrix:we,calcVectorRotation:is,cancelAnimFrame:dt,capValue:ds,composeMatrix:Lt,copyCanvasElement:t=>{var e;const s=vt(t);return null===(e=s.getContext("2d"))||void 0===e||e.drawImage(t,0,0),s},cos:rt,createCanvasElement:pt,createImage:mt,createRotateMatrix:Mt,createScaleMatrix:Pt,createSkewXMatrix:At,createSkewYMatrix:jt,createTranslateMatrix:Dt,createVector:ts,crossProduct:os,degreesToRadians:_t,dotProduct:as,ease:Cs,enlivenObjectEnlivables:Bt,enlivenObjects:It,findScaleToCover:Pr,findScaleToFit:Mr,getBoundsOfCurve:Ir,getOrthonormalVector:ns,getPathSegmentsInfo:Jr,getPointOnPath:Qr,getPointer:ge,getRandomInt:an,getRegularPolygonPath:(t,e)=>{const s=2*Math.PI/t;let i=-b;t%2==0&&(i+=s/2);const r=new Array(t+1);for(let n=0;n{const e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},getUnitVector:rs,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new Dr(t,e),hasStyleChanged:Pi,invertTransform:wt,isBetweenVectors:hs,isIdentityMatrix:Ct,isTouchEvent:fe,isTransparent:_i,joinPath:nn,loadImage:Rt,magnitude:es,makeBoundingBoxFromPoints:me,makePathSimpler:Xr,matrixToSVG:Qt,mergeClipPaths:(t,e)=>{var s;let i=t,r=e;i.inverted&&!r.inverted&&(i=e,r=t),Oe(r,null===(s=r.group)||void 0===s?void 0:s.calcTransformMatrix(),i.calcTransformMatrix());const n=i.inverted&&r.inverted;return n&&(i.inverted=r.inverted=!1),new Dr([i],{clipPath:r,inverted:n})},multiplyTransformMatrices:St,multiplyTransformMatrixArray:Tt,parsePath:sn,parsePreserveAspectRatioAttribute:Jt,parseUnit:Kt,pick:Xt,projectStrokeOnPoints:Si,qrDecompose:kt,radiansToDegrees:xt,removeFromArray:it,removeTransformFromObject:(t,e)=>{const s=wt(e),i=St(s,t.calcOwnMatrix());_e(t,i)},removeTransformMatrixForSvgParsing:cn,request:hn,requestAnimFrame:ut,resetObjectTransform:xe,rotatePoint:(t,e,s)=>t.rotate(s,e),rotateVector:$e,saveObjectTransform:Ce,sendObjectToPlane:Oe,sendPointToPlane:Se,sendVectorToPlane:Te,setStyle:on,sin:nt,sizeAfterTransform:be,string:Mi,stylesFromArray:Ai,stylesToArray:Ei,toDataURL:yt,toFixed:qt,transformPath:(t,e,s)=>(s&&(e=St(e,[1,0,0,1,-s.x,-s.y])),t.map((t=>{const s=[...t];for(let i=1;i1&&void 0!==arguments[1]?arguments[1]:{};super(t),e(this,"upper",void 0),e(this,"container",void 0);const{el:r}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:s}),this.applyCanvasStyle(n,{allowTouchScrolling:s,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=pt();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=m().createElement("div");return t.setAttribute("data-fabric","wrapper"),on(t,{position:"relative"}),he(t),t}applyCanvasStyle(t,e){const{styles:s,allowTouchScrolling:r}=e;on(t,i(i({},s),{},{"touch-action":r?"manipulation":j})),he(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:s,ctx:i}=this.upper;oe(s,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),ae(this.upper.el,t),ae(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(),p().dispose(this.upper.el),delete this.upper,delete this.container}}class dn extends ue{constructor(){super(...arguments),e(this,"targets",[]),e(this,"_hoveredTargets",[]),e(this,"_objectsToRender",void 0),e(this,"_currentTransform",null),e(this,"_groupSelector",null),e(this,"contextTopDirty",!1)}static getDefaults(){return i(i({},super.getDefaults()),dn.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 un(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)}isTargetTransparent(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 _i(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===z||e===H||e===N||e===Y?i=this.centeredScaling||t.centeredScaling:e===B&&(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=A:["mr","tr","br"].includes(e)&&(s.x=M),["tl","mt","tr"].includes(e)?s.y=E:["bl","mb","br"].includes(e)&&(s.y=P),s):s}_setupCurrentTransform(t,e,s){var r;const n=e.group?Se(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},h=s&&a?null===(r=a.getActionHandler(t,e,a))||void 0===r?void 0:r.bind(a):Ie,c=((t,e,s,i)=>{if(!e||!t)return"drag";const r=i.controls[e];return r.getActionName(s,r,i)})(s,o,t,e),l=t[this.centeredKey],u=this._shouldCenterTransform(e,c,l)?{x:D,y:D}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:h,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:_t(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:l,original:i(i({},Ce(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new ot(e,s).transform(this.viewportTransform),o=new ot(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,yi.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,fe(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=rt(o)*r,h=nt(o)*r,c=a+h,l=a-h;s=[new ot(t.x-l,t.y-c),new ot(e.x+c,e.y-l),new ot(i.x+l,i.y+c),new ot(n.x-c,n.y+l)]}return Fs.isPointInPolygon(e,s)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Se(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;if(!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(ht(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&&ht(s)&&s.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const s=t[e];if(!ht(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=ge(t),n=i.width||0,o=i.height||0;n&&o||(P in i&&E in i&&(o=Math.abs(i.top-i.bottom)),A in i&&M 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=Se(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const h=0===n||0===o?new ot(1,1):new ot(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=pt(),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 se(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,se(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),se(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(Q,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;se(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&&se(e)&&this._activeObject===e){const s=Xt(t,["angle","flipX","flipY",M,H,N,U,q,P]);return ye(t,e.calcOwnMatrix()),s}return{}}_setSVGObject(t,e,s){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,s),e.set(i)}}e(dn,"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,hoverCursor:"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 gn{constructor(t){e(this,"targets",[]),e(this,"__disposer",void 0);const s=()=>{const{hiddenTextarea:e}=t.getActiveObject()||{};e&&e.focus()},i=t.upperCanvasEl;i.addEventListener("click",s),this.__disposer=()=>i.removeEventListener("click",s)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),it(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 fn=["target","oldTarget","fireCanvas","e"],pn={passive:!1},mn=(t,e)=>{const s=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:s,scenePoint:i,pointer:s,absolutePointer:i}},vn=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{}),e(this,"_isClick",void 0),e(this,"textEditingManager",new gn(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((t=>{this[t]=this[t].bind(this)})),this.addOrRemove(vn,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const s=this.upperCanvasEl,i=this._getEventPrefix();t(ne(s),"resize",this._onResize),t(s,i+"down",this._onMouseDown),t(s,"".concat(i,"move"),this._onMouseMove,pn),t(s,"".concat(i,"out"),this._onMouseOut),t(s,"".concat(i,"enter"),this._onMouseEnter),t(s,"wheel",this._onMouseWheel),t(s,"contextmenu",this._onContextMenu),t(s,"dblclick",this._onDoubleClick),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,pn)}removeListeners(){this.addOrRemove(yn,"remove");const t=this._getEventPrefix(),e=re(this.upperCanvasEl);yn(e,"".concat(t,"up"),this._onMouseUp),yn(e,"touchend",this._onTouchEnd,pn),yn(e,"".concat(t,"move"),this._onMouseMove,pn),yn(e,"touchmove",this._onMouseMove,pn),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,s=i({e:t},mn(this,t));this.fire("mouse:out",i(i({},s),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",i({},s)),this._hoveredTargets.forEach((t=>{this.fire("mouse:out",i(i({},s),{},{target:t})),t&&t.fire("mouseout",i({},s))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",i({e:t},mn(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 vn(this.upperCanvasEl,"drag",this._onDragProgress)}pe(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(),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!==j,s=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:s};yn(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){this.targets=[];return{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 s=0;s0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),s=re(this.upperCanvasEl);yn(s,"touchend",this._onTouchEnd,pn),yn(s,"touchmove",this._onMouseMove,pn),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{vn(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=re(this.upperCanvasEl);yn(t,"".concat(s,"up"),this._onMouseUp),yn(t,"".concat(s,"move"),this._onMouseMove,pn),vn(e,"".concat(s,"move"),this._onMouseMove,pn)}}_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");const 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),fe(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{s=t.hoverCursor||s})),this.setCursor(s)}handleMultiSelection(t,e){const s=this._activeObject,i=se(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(tt.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 ot(e,s),o=n.add(new ot(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=tt.getClass("ActiveSelection");this.setActiveObject(new e(l,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const Cn={x1:0,y1:0,x2:0,y2:0},bn=i(i({},Cn),{},{r1:0,r2:0}),wn=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,Sn=/^(\d+\.\d+)%|(\d+)%$/;function Tn(t){return t&&Sn.test(t)}function On(t,e){const s="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(Tn(t)?100:1):NaN;return ds(0,wn(s,e),1)}const kn=/\s*;\s*/,Dn=/\s*:\s*/;function Mn(t,e){let s,i;const r=t.getAttribute("style");if(r){const t=r.split(kn);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,n]=t[e].split(Dn).map((t=>t.trim()));"stop-color"===r?s=n:"stop-opacity"===r&&(i=n)}}const n=new Ut(s||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:On(t.getAttribute("offset"),0),color:n.toRgb(),opacity:wn(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*n.getAlpha()*e}}function Pn(t,e){const s=[],i=t.getElementsByTagName("stop"),r=On(e,1);for(let t=i.length;t--;)s.push(Mn(i[t],r));return s}function En(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function An(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function jn(t,e){return t.getAttribute(e)}function Fn(t,e){return function(t,e){let s,{width:i,height:r,gradientUnits:n}=e;return Object.keys(t).reduce(((e,o)=>{const a=t[o];return"Infinity"===a?s=1:"-Infinity"===a?s=0:(s="string"==typeof a?parseFloat(a):a,"string"==typeof a&&Tn(a)&&(s*=.01,"pixels"===n&&("x1"!==o&&"x2"!==o&&"r2"!==o||(s*=i),"y1"!==o&&"y2"!==o||(s*=r)))),e[o]=s,e}),{})}("linear"===En(t)?function(t){return{x1:jn(t,"x1")||0,y1:jn(t,"y1")||0,x2:jn(t,"x2")||"100%",y2:jn(t,"y2")||0}}(t):function(t){return{x1:jn(t,"fx")||jn(t,"cx")||"50%",y1:jn(t,"fy")||jn(t,"cy")||"50%",r1:0,x2:jn(t,"cx")||"50%",y2:jn(t,"cy")||"50%",r2:jn(t,"r")||"50%"}}(t),i(i({},e),{},{gradientUnits:An(t)}))}class Ln{constructor(t){const{type:e="linear",gradientUnits:s="pixels",coords:r={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:h,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:s,coords:i(i({},"radial"===e?bn:Cn),r),colorStops:n,offsetX:o,offsetY:a,gradientTransform:h,id:c?"".concat(c,"_").concat(ft()):ft()})}addColorStop(t){for(const e in t){const s=new Ut(t[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this}toObject(t){return i(i({},Xt(this,t)),{},{type:this.type,coords:i({},this.coords),colorStops:this.colorStops.map((t=>i({},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=[],r=this.gradientTransform?this.gradientTransform.concat():T.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((t=>i({},t))).sort(((t,e)=>t.offset-e.offset));let a=-this.offsetX,h=-this.offsetY;var c;"objectBoundingBox"===n?(a/=t.width,h/=t.height):(a+=t.width/2,h+=t.height/2),(c=t)&&"function"==typeof c._renderPathCommands&&"percentage"!==this.gradientUnits&&(a-=t.pathOffset.x,h-=t.pathOffset.y),r[4]-=a,r[5]-=h;const l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Qt(r),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:i,y2:r}=this.coords;s.push("\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:i,y2:r,r1:n,r2:a}=this.coords,h=n>a;s.push("\n'),h&&(o.reverse(),o.forEach((t=>{t.offset=1-t.offset})));const c=Math.min(n,a);if(c>0){const t=c/Math.max(n,a);o.forEach((e=>{e.offset+=t*(1-e.offset)}))}}return o.forEach((t=>{let{color:e,offset:i,opacity:r}=t;s.push("\n')})),s.push("linear"===this.type?"":"","\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 Ut(e).setAlpha(s).toRgba():e)})),a}static async fromObject(t){const{colorStops:e,gradientTransform:s}=t;return new this(i(i({},t),{},{colorStops:e?e.map((t=>i({},t))):void 0,gradientTransform:s?[...s]:void 0}))}static fromElement(t,e,s){const r=An(t),n=e._findCenterFromElement();return new this(i({id:t.getAttribute("id")||void 0,type:En(t),coords:Fn(t,{width:s.viewBoxWidth||s.width,height:s.viewBoxHeight||s.height}),colorStops:Pn(t,s.opacity),gradientUnits:r,gradientTransform:nr(t.getAttribute("gradientTransform")||"")},"pixels"===r?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}e(Ln,"type","Gradient"),tt.setClass(Ln,"gradient"),tt.setClass(Ln,"linear"),tt.setClass(Ln,"radial");const Rn=["type","source","patternTransform"];class In{get type(){return"pattern"}set type(t){h("warn","Setting type has no effect",t)}constructor(t){e(this,"repeat","repeat"),e(this,"offsetX",0),e(this,"offsetY",0),e(this,"crossOrigin",""),this.id=ft(),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 i(i({},Xt(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:s,offsetX:qt(this.offsetX,a.NUM_FRACTION_DIGITS),offsetY:qt(this.offsetY,a.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=wn(this.offsetX/e,0),a=wn(this.offsetY/s,0),h="repeat-y"===r||"no-repeat"===r?1+Math.abs(o||0):wn(i.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):wn(i.height/s,0);return[''),''),"",""].join("\n")}static async fromObject(t,e){let{type:s,source:n,patternTransform:o}=t,a=r(t,Rn);const h=await Rt(n,i(i({},e),{},{crossOrigin:a.crossOrigin}));return new this(i(i({},a),{},{patternTransform:o&&o.slice(0),source:h}))}}e(In,"type","Pattern"),tt.setClass(In),tt.setClass(In,"pattern");class Bn{constructor(t){e(this,"color","rgb(0, 0, 0)"),e(this,"width",1),e(this,"shadow",null),e(this,"strokeLineCap","round"),e(this,"strokeLineJoin","round"),e(this,"strokeMiterLimit",10),e(this,"strokeDashArray",null),e(this,"limitedToCanvasSize",!1),this.canvas=t}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new Ut(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,s=t.contextTop,i=t.getZoom()*t.getRetinaScaling();s.shadowColor=e.color,s.shadowBlur=e.blur*i,s.shadowOffsetX=e.offsetX*i,s.shadowOffsetY=e.offsetY*i}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}const Xn=["path","left","top"],Yn=["d"];class Wn extends yi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:s,left:i,top:n}=e,o=r(e,Xn);super(),Object.assign(this,Wn.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),"number"==typeof i&&this.set(M,i),"number"==typeof n&&this.set(P,n)}_setPath(t,e){this.path=Xr(Array.isArray(t)?t:sn(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new ot(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"#")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return i(i({},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=nn(this.path,a.NUM_FRACTION_DIGITS);return["\n')]}_getOffsetTransform(){const t=a.NUM_FRACTION_DIGITS;return" translate(".concat(qt(-this.pathOffset.x,t),", ").concat(qt(-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,D,D)}_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(...Ir(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(...Ir(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 me(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return i(i({},t),{},{pathOffset:new ot(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 n=ur(t,this.ATTRIBUTE_NAMES,s),{d:o}=n;return new this(o,i(i(i({},r(n,Yn)),e),{},{left:void 0,top:void 0}))}}e(Wn,"type","Path"),e(Wn,"cacheProperties",[...fs,"path","fillRule"]),e(Wn,"ATTRIBUTE_NAMES",[...ji,"d"]),tt.setClass(Wn),tt.setSVGClass(Wn);class Vn extends Bn{constructor(t){super(t),e(this,"decimate",.4),e(this,"drawStraightLine",!1),e(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,s){const i=e.midPointFrom(s);return t.quadraticCurveTo(e.x,e.y,i.x,i.y),i}onMouseDown(t,e){let{e:s}=e;this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:s}=e;if(this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const t=this._points,e=t.length,s=this.canvas.contextTop;this._saveAndTransform(s),this.oldEnd&&(s.beginPath(),s.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=Vn.drawSegment(s,t[e-2],t[e-1]),s.stroke(),s.restore()}}onMouseUp(t){let{e:e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvas.contextTop,e=this._points[0],s=this._points[1];if(this._saveAndTransform(t),t.beginPath(),2===this._points.length&&e.x===s.x&&e.y===s.y){const t=this.width/1e3;e.x-=t,s.x+=t}t.moveTo(e.x,e.y);for(let i=1;i=n&&(i=t[e],a.push(i));return a.push(t[o]),a}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(t){return"M 0 0 Q 0 0 0 0 L 0 0"===nn(t)}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const Gn=["left","top","radius"],zn=["radius","startAngle","endAngle","counterClockwise"];class Hn extends yi{static getDefaults(){return i(i({},super.getDefaults()),Hn.ownDefaults)}constructor(t){super(),Object.assign(this,Hn.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,_t(this.startAngle),_t(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(H)}getRadiusY(){return this.get("radius")*this.get(N)}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([...zn,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["\n'];{const{radius:e}=this,s=_t(this.startAngle),i=_t(this.endAngle),r=rt(s)*e,n=nt(s)*e,o=rt(i)*e,a=nt(i)*e,h=t>180?1:0,c=this.counterClockwise?0:1;return['\n"]}}static async fromElement(t,e,s){const n=ur(t,this.ATTRIBUTE_NAMES,s),{left:o=0,top:a=0,radius:h=0}=n;return new this(i(i({},r(n,Gn)),{},{radius:h,left:o-h,top:a-h}))}static fromObject(t){return super._fromObject(t)}}e(Hn,"type","Circle"),e(Hn,"cacheProperties",[...fs,...zn]),e(Hn,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),e(Hn,"ATTRIBUTE_NAMES",["cx","cy","r",...ji]),tt.setClass(Hn),tt.setSVGClass(Hn);const Nn=["x1","y1","x2","y2"],Un=["x1","y1","x2","y2"],qn=["x1","x2","y1","y2"];class Kn extends yi{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,Kn.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(M,n),"number"==typeof o&&this.set(P,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}=me([{x:t,y:e},{x:s,y:i}]),h=new ot(r+o/2,n+a/2);this.setPositionByOrigin(h,D,D)}_set(t,e){return super._set(t,e),qn.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;$t(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 ot((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return i(i({},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["\n')]}static async fromElement(t,e,s){const i=ur(t,this.ATTRIBUTE_NAMES,s),{x1:n=0,y1:o=0,x2:a=0,y2:h=0}=i;return new this([n,o,a,h],r(i,Nn))}static fromObject(t){let{x1:e,y1:s,x2:n,y2:o}=t,a=r(t,Un);return this._fromObject(i(i({},a),{},{points:[e,s,n,o]}),{extraParam:"points"})}}e(Kn,"type","Line"),e(Kn,"cacheProperties",[...fs,...qn]),e(Kn,"ATTRIBUTE_NAMES",ji.concat(qn)),tt.setClass(Kn),tt.setSVGClass(Kn);class Jn extends yi{static getDefaults(){return i(i({},super.getDefaults()),Jn.ownDefaults)}constructor(t){super(),Object.assign(this,Jn.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["']}}e(Jn,"type","Triangle"),e(Jn,"ownDefaults",{width:100,height:100}),tt.setClass(Jn),tt.setSVGClass(Jn);const Qn=["rx","ry"];class Zn extends yi{static getDefaults(){return i(i({},super.getDefaults()),Zn.ownDefaults)}constructor(t){super(),Object.assign(this,Zn.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(H)}getRy(){return this.get("ry")*this.get(N)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...Qn,...t])}_toSVG(){return["\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,w,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,s){const i=ur(t,this.ATTRIBUTE_NAMES,s);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}function $n(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),s=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),e(this,"strokeDiff",void 0),Object.assign(this,so.ownDefaults),this.setOptions(s),this.points=t;const{left:i,top:r}=s;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(M,i),"number"==typeof r&&this.set(P,r)}isOpen(){return!0}_projectStrokeOnPoints(t){return Si(this.points,t,this.isOpen())}_calcDimensions(t){t=i({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 ot,strokeOffset:new ot,strokeDiff:new ot};const s=me(e),r=Ft(i(i({},t),{},{scaleX:1,scaleY:1})),n=me(this.points.map((t=>bt(t,r,!0)))),o=new ot(this.scaleX,this.scaleY);let a=s.left+s.width/2,h=s.top+s.height/2;return this.exactBoundingBox&&(a-=h*Math.tan(_t(this.skewX)),h-=a*Math.tan(_t(this.skewY))),i(i({},s),{},{pathOffset:new ot(a,h),strokeOffset:new ot(n.left,n.top).subtract(new ot(s.left,s.top)).multiply(o),strokeDiff:new ot(s.width,s.height).subtract(new ot(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=me(this.points);return new ot(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 ot(e+i/2,s+r/2),D,D)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new ot(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 ot(null!==(e=t.width)&&void 0!==e?e:i,null!==(s=t.height)&&void 0!==s?s:r)}else{var i,r;n=new ot(null!==(i=t.width)&&void 0!==i?i:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return n.multiply(new ot(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===H||t===N)&&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 i(i({},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=a.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r\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;rvoid 0!==t));this._setStyleDeclaration(s,r,n)}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 i(i({},Xt(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]}}e(po,"_styleProperties",ho);const mo=/ +/g,vo=/"/g;function yo(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]:a.NUM_FRACTION_DIGITS;const h=Zt(K,t,!1),[c,l,u,d]=[s,i,r,n].map((t=>qt(t,o)));return"')}(t,{left:e,top:s,width:i,height:r}),"\n")}const _o=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let xo;class Co extends po{static getDefaults(){return i(i({},super.getDefaults()),Co.ownDefaults)}constructor(t,s){super(),e(this,"__charBounds",[]),Object.assign(this,Co.ownDefaults),this.setOptions(s),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=Jr(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(lo)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,s,i,r,n,o;for(let a=0,h=this._textLines.length;a')}_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===J?(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 D:t.textBaseline="middle";break;case"ascender":t.textBaseline=P;break;case"descender":t.textBaseline=E}t.font=this._getFontDeclaration(e,s)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,s=this._textLines.length;et&&(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 e=0,r=this._textLines.length;e=0:ie?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=Qr(i.path,s,i.segmentsInfo);e.renderLeft=r.x-i.pathOffset.x,e.renderTop=r.y-i.pathOffset.y,e.angle=r.angle+(this.pathSide===A?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}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let s=1,i=this._textLines[t].length;s0){let e=i+u+f;"rtl"===this.direction&&(e=this.width-e-p),m&&v&&(t.fillStyle=v,t.fillRect(e,y+o*_+x,p,this.fontSize/15)),f=n.left,p=n.width,m=d,v=g,_=h,x=c}else p+=n.kernedWidth}let C=i+u+f;"rtl"===this.direction&&(C=this.width-C-p),t.fillStyle=g,d&&g&&t.fillRect(C,y+o*_+x,p-n,this.fontSize/15),s+=h}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(",")||Co.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 ki(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),s=new Array(e.length),i=["\n"];let r=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return i(i({},super.toObject([...ao,...t])),{},{styles:Ei(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 e in t)"path"===e&&this.setPathInfo(),i=i||s.includes(e),r=r||"path"===e;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 n=ur(t,Co.ATTRIBUTE_NAMES,s),o=i(i({},e),n),{textAnchor:a=M,textDecoration:h="",dx:c=0,dy:l=0,top:u=0,left:d=0,fontSize:g=O,strokeWidth:f=1}=o,p=r(o,_o),m=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),i({left:d+c,top:u+l,underline:h.includes("underline"),overline:h.includes("overline"),linethrough:h.includes("line-through"),strokeWidth:0,fontSize:g},p)),v=m.getScaledHeight()/m.height,y=((m.height+m.strokeWidth)*m.lineHeight-m.height)*v,_=m.getScaledHeight()+y;let x=0;return a===D&&(x=m.getScaledWidth()/2),a===A&&(x=m.getScaledWidth()),m.set({left:m.left-x,top:m.top-(_-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:f}),m}static fromObject(t){return this._fromObject(i(i({},t),{},{styles:Ai(t.styles||{},t.text)}),{extraParam:"text"})}}e(Co,"textLayoutProperties",oo),e(Co,"cacheProperties",[...fs,...ao]),e(Co,"ownDefaults",co),e(Co,"type","Text"),e(Co,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),e(Co,"ATTRIBUTE_NAMES",ji.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),vi(Co,[class extends Be{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})}_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",s.join(""),"\n"]}_getSVGTextAndBg(t,e){const s=[],i=[];let r,n=t;this.backgroundColor&&i.push(...yo(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t").concat(Oi(t),"")}_setSVGTextLineText(t,e,s,i){const r=this.getHeightOfLine(e),n=this.textAlign.includes(lo),o=this._textLines[e];let a,h,c,l,u,d="",g=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let r=0,f=o.length-1;r<=f;r++)u=r===f||this.charSpacing,d+=o[r],c=this.__charBounds[e][r],0===g?(s+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[r])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(e,r),h=this.getCompleteStyleDeclaration(e,r+1),u=Pi(a,h,!0)),u&&(l=this._getStyleDeclaration(e,r),t.push(this._createTextCharSpan(d,l,s,i)),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;lt[e.replace("-","")])).join(" ")}}]),tt.setClass(Co),tt.setSVGClass(Co);class bo{constructor(t){e(this,"target",void 0),e(this,"__mouseDownInPlace",!1),e(this,"__dragStartFired",!1),e(this,"__isDraggingOver",!1),e(this,"__dragStartSelection",void 0),e(this,"__dragImageDisposer",void 0),e(this,"_dispose",void 0),this.target=t;const s=[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=()=>{s.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{_.remove()},re(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},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),n=i({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}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 es.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;if(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(G,{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)||j;o===j?(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(G,{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 wo=/[ \n\.,;!\?\-]/;class So extends Co{constructor(){super(...arguments),e(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 As({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}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-1;)e++,s--;return t-e}findLineBoundaryRight(t){let e=0,s=t;for(;!/\n/.test(this._text[s])&&s0&&this._reSpace.test(s[t])&&(-1===e||!F.test(s[t-1]))?t-1:t,r=s[i];for(;i>0&&ithis.__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()))}_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;if(t===e)return{selectionStart:i,selectionEnd:i};return{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 ot(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new ot(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(Q),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=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,r){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let h=!1;s||(s=1),this.shiftLineStyles(t,s);const c=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const s in this.styles[t]){const i=parseInt(s,10);i>=e&&(h=!0,n[i-e]=this.styles[t][s],a&&0===e||delete this.styles[t][s])}let l=!1;for(h&&!a&&(this.styles[t+s]=n,l=!0),(l||o>e)&&s--;s>0;)r&&r[s-1]?this.styles[t+s]={0:i({},r[s-1])}:c?this.styles[t+s]={0:i({},c)}:delete this.styles[t+s],s--;this._forceClearCache=!0}insertCharStyleObject(t,e,s,r){this.styles||(this.styles={});const n=this.styles[t],o=n?i({},n):{};s||(s=1);for(const t in o){const i=parseInt(t,10);i>=e&&(n[i+s]=o[i],o[i-s]||delete n[i])}if(this._forceClearCache=!0,r){for(;s--;)Object.keys(r[s]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+s]=i({},r[s]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&s--;)this.styles[t][e+s]=i({},a)}insertNewStyleBlock(t,e,s){const i=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let e=0;e0&&(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;n0?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=M:this._selectionDirection===A&&(this._selectionDirection=M,this.selectionEnd=t),this.selectionStart=s):s>t&&s{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,"; 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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const s=()=>{this.updateFromTextArea(),this.fire(G),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void s();const i=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,n=i.length,o=this.selectionStart,h=this.selectionEnd,c=o!==h;let l,u,d,g,f=n-r;const m=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),v=o>m.selectionStart;c?(u=this._text.slice(o,h),f+=h-o):nl[0]))),c?(d=o,g=h):v?(d=h-u.length,g=h):(d=h,g=h+u.length),this.removeStyleFromTo(d,g)),y.length){const{copyPasteData:t}=p();e&&y.join("")===t.copiedText&&!a.disableStyleCopyPaste&&(l=t.copiedTextStyle),this.insertNewStyleBlock(y,o,l)}s()}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}=p();t.copiedText=this.getSelectedText(),a.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;ae){r=!0;const t=n-i,s=n,h=Math.abs(t-e);o=Math.abs(s-e)=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===A);if(e.shiftKey?this.moveCursorWithShift(s):this.moveCursorWithoutShift(s),0!==s){const t=this.text.length;this.selectionStart=ds(0,this.selectionStart,t),this.selectionEnd=ds(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===M?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;if(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=M,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===A&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=M,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===M&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=A,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=A,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Oo=t=>!!t.button;class ko extends To{constructor(){super(...arguments),e(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new bo(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),pe(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e:e}=t;this.canvas&&this.editable&&!Oo(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e:e}=t;this.canvas&&this.editable&&!Oo(e)&&(this.selected=this===this.canvas._activeObject)}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||Oo(e)||i||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}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(wt(this.calcTransformMatrix())).add(new ot(-this._getLeftOffset(),-this._getTopOffset()));let s=0,i=0,r=0;for(let t=0;t0&&(i+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,a=this.__charBounds[r];for(let t=0;t0&&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)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_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 t=0;t0?s:0)};return"rtl"===this.direction&&(this.textAlign===A||this.textAlign===lo||this.textAlign===go?a.left*=-1:this.textAlign===M||this.textAlign===uo?a.left=n-(s>0?s:0):this.textAlign!==D&&this.textAlign!==fo||(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(lo),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 e=h;e<=c;e++){const i=this._getLineLeftOffset(e)||0;let r=this.getHeightOfLine(e),o=0,a=0,d=0;if(e===h&&(a=this.__charBounds[h][l].left),e>=h&&e1)&&(r/=this.lineHeight);let g=s.left+i+a,f=r,p=0;const m=d-a;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",f=1,p=r):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===A||this.textAlign===lo||this.textAlign===go?g=this.width-g-m:this.textAlign===M||this.textAlign===uo?g=s.left+i-d:this.textAlign!==D&&this.textAlign!==fo||(g=s.left+i-d)),t.fillRect(g,s.top+s.topOffset+p,m,f),s.topOffset+=o}}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,K)}_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()}}e(Fo,"ownDefaults",jo),e(Fo,"type","IText"),tt.setClass(Fo),tt.setClass(Fo,"i-text");class Lo extends Fo{static getDefaults(){return i(i({},super.getDefaults()),Lo.ownDefaults)}constructor(t,e){super(t,i(i({},Lo.ownDefaults),e))}static createControls(){return{controls:pi()}}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(lo)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,s=0,i=0;const r={};for(let n=0;n0?(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 t in a)for(const i in a[t]){const n=parseInt(i,10);if(n>=s&&(!r||n{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;n3&&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;vp&&!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 t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}e(Lo,"type","Textbox"),e(Lo,"textLayoutProperties",[...Fo.textLayoutProperties,"width"]),e(Lo,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tt.setClass(Lo);class Ro extends xr{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}=me(_r(s,i)),a=new ot(n,o);if(i.absolutePositioned){return{center:Se(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 ot,correction:i=new ot}=this.calcBoundingBox(e,t)||{};return{center:s.add(r),correction:i.subtract(r),size:a}}return{center:s.getRelativeCenterPoint().add(r),size:a}}}}e(Ro,"type","clip-path"),tt.setClass(Ro);class Io extends xr{getInitialSize(t,e){let{target:s}=t,{size:i}=e;return new ot(s.width||i.x,s.height||i.y)}}e(Io,"type","fixed"),tt.setClass(Io);class Bo extends Tr{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 Xo extends Dr{static getDefaults(){return i(i({},super.getDefaults()),Xo.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,Xo.ownDefaults),this.setOptions(e);const{left:s,top:i,layoutManager:r}=e;this.groupInit(t,{left:s,top:i,layoutManager:null!=r?r:new Bo})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),s=0;s{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)))?(h("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)})),t===vr?s.forEach((t=>{t._onAfterObjectsChange(mr,e)})):s.forEach((t=>{t._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,s){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const r=i(i({hasControls:!1},s),{},{forActiveSelection:!0});for(let e=0;e{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 Wo{constructor(){let{tileSize:t=a.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),e(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=vt({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 Vo;function Go(){const{WebGLProbe:t}=p();return t.queryWebGL(pt()),a.enableGLFiltering&&t.isSupported(a.textureSize)?new Wo({tileSize:a.textureSize}):new Yo}function zo(){return!Vo&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(Vo=Go()),Vo}const Ho=["filters","resizeFilter","src","crossOrigin","type"],No=["cropX","cropY"];class Uo extends yi{static getDefaults(){return i(i({},super.getDefaults()),Uo.ownDefaults)}constructor(t,s){super(),e(this,"_lastScaleX",1),e(this,"_lastScaleY",1),e(this,"_filterScalingX",1),e(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Uo.ownDefaults),this.setOptions(s),this.cacheKey="texture".concat(ft()),this.setElement("string"==typeof t?(this.canvas&&re(this.canvas.getElement())||m()).getElementById(t):t,s)}getElement(){return this._element}setElement(t){let e=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(e),t.classList.add(Uo.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=zo(!1);e instanceof Wo&&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&&p().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())})),i(i({},super.toObject([...No,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width\n','\t\n',"\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,n=['\t\n')],this.fill=t}return r=this.paintFirst!==K?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 Rt(t,{crossOrigin:e,signal:s}).then((t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)}))}toString(){return'#')}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=vt(n),{width:a,height:h}=n;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=r,zo().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=vt({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);zo().applyFilters(t,this._originalElement,s,i,this._element),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.naturalWidth||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=Jt(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===j&&t.alignY===j?(a=e/n,h=s/o):("meet"===t.meetOrSlice&&(a=h=Mr(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=Pr(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:n,src:o,crossOrigin:a,type:h}=t,c=r(t,Ho);return Promise.all([Rt(o,i(i({},e),{},{crossOrigin:a})),s&&It(s,e),n&&It([n],e),Bt(c,e)]).then((t=>{let[e,s=[],[r]=[],n={}]=t;return new this(e,i(i({},c),{},{src:o,filters:s,resizeFilter:r},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 Rt(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=ur(t,this.ATTRIBUTE_NAMES,s);return this.fromURL(i["xlink:href"],e,i).catch((t=>(h("log","Unable to parse Image",t),null)))}}function qo(t){if(!qe.test(t.nodeName))return{};const e=t.getAttribute("viewBox");let s,i,r=1,n=1,o=0,a=0;const h=t.getAttribute("width"),c=t.getAttribute("height"),l=t.getAttribute("x")||0,u=t.getAttribute("y")||0,d=!(e&&Je.test(e)),g=!h||!c||"100%"===h||"100%"===c;let f="",p=0,m=0;if(d&&(l||u)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") ",s=(t.getAttribute("transform")||"")+f,t.setAttribute("transform",s),t.removeAttribute("x"),t.removeAttribute("y")),d&&g)return{width:0,height:0};const v={width:0,height:0};if(d)return v.width=Kt(h),v.height=Kt(c),v;const y=e.match(Je);o=-parseFloat(y[1]),a=-parseFloat(y[2]);const _=parseFloat(y[3]),x=parseFloat(y[4]);v.minX=o,v.minY=a,v.viewBoxWidth=_,v.viewBoxHeight=x,g?(v.width=_,v.height=x):(v.width=Kt(h),v.height=Kt(c),r=v.width/_,n=v.height/x);const C=Jt(t.getAttribute("preserveAspectRatio")||"");if(C.alignX!==j&&("meet"===C.meetOrSlice&&(n=r=r>n?n:r),"slice"===C.meetOrSlice&&(n=r=r>n?r:n),p=v.width-_*r,m=v.height-x*r,"Mid"===C.alignX&&(p/=2),"Mid"===C.alignY&&(m/=2),"Min"===C.alignX&&(p=0),"Min"===C.alignY&&(m=0)),1===r&&1===n&&0===o&&0===a&&0===l&&0===u)return v;if((l||u)&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") "),s=f+" matrix("+r+" 0 0 "+n+" "+(o*r+p)+" "+(a*n+m)+") ","svg"===t.nodeName){for(i=t.ownerDocument.createElementNS(Ve,"g");t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i)}else i=t,i.removeAttribute("x"),i.removeAttribute("y"),s=i.getAttribute("transform")+s;return i.setAttribute("transform",s),v}e(Uo,"type","Image"),e(Uo,"cacheProperties",[...fs,...No]),e(Uo,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),e(Uo,"CSS_CANVAS","canvas-img"),e(Uo,"ATTRIBUTE_NAMES",[...ji,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),tt.setClass(Uo),tt.setSVGClass(Uo);const Ko=t=>t.tagName.replace("svg:",""),Jo=Xe(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);function Qo(t,e){let s,i,r,n,o=[];for(r=0,n=e.length;r{const s=r.getAttribute(t);!e.hasAttribute(t)&&s&&e.setAttribute(t,s)})),!e.children.length)){const t=r.cloneNode(!0);for(;t.firstChild;)e.appendChild(t.firstChild)}e.removeAttribute($o)}const ea=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"];function sa(t){const e=t.getElementsByTagName("style");let s,r;const n={};for(s=0,r=e.length;ss.length>1&&t.trim())).forEach((t=>{if((t.match(/{/g)||[]).length>1&&t.trim().startsWith("@"))return;const e=t.split("{"),o={},a=e[1].trim().split(";").filter((function(t){return t.trim()}));for(s=0,r=a.length;s{""!==(t=t.replace(/^svg/i,"").trim())&&(n[t]=i(i({},n[t]||{}),o))}))}))}return n}const ia=t=>tt.getSVGClass(Ko(t).toLowerCase());class ra{constructor(t,e,s,i,r){this.elements=t,this.options=e,this.reviver=s,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=i,this.clipPaths=r,this.gradientDefs=function(t){const e=Qo(t,ea),s={};let i=e.length;for(;i--;){const r=e[i];r.getAttribute("xlink:href")&&ta(t,r);const n=r.getAttribute("id");n&&(s[n]=r)}return s}(i),this.cssRules=sa(i)}parse(){return Promise.all(this.elements.map((t=>this.createObject(t))))}async createObject(t){const e=ia(t);if(e){const s=await e.fromElement(t,this.options,this.cssRules);return this.resolveGradient(s,t,K),this.resolveGradient(s,t,J),s instanceof Uo&&s._originalElement?cn(s,s.parsePreserveAspectRatioAttribute()):cn(s),await this.resolveClipPath(s,t),this.reviver&&this.reviver(t,s),s}return null}extractPropertyDefinition(t,e,s){const i=t[e],r=this.regexUrl;if(!r.test(i))return;r.lastIndex=0;const n=r.exec(i)[1];return r.lastIndex=0,s[n]}resolveGradient(t,e,s){const r=this.extractPropertyDefinition(t,s,this.gradientDefs);if(r){const n=e.getAttribute(s+"-opacity"),o=Ln.fromElement(r,t,i(i({},this.options),{},{opacity:n}));t.set(s,o)}}async resolveClipPath(t,e,s){const i=this.extractPropertyDefinition(t,"clipPath",this.clipPaths);if(i){const r=wt(t.calcTransformMatrix()),n=i[0].parentElement;let o=e;for(;!s&&o.parentElement&&o.getAttribute("clip-path")!==t.clipPath;)o=o.parentElement;o.parentElement.appendChild(n);const a=nr("".concat(o.getAttribute("transform")||""," ").concat(n.getAttribute("originalTransform")||""));n.setAttribute("transform","matrix(".concat(a.join(","),")"));const h=await Promise.all(i.map((t=>ia(t).fromElement(t,this.options,this.cssRules).then((t=>(cn(t),t.fillRule=t.clipRule,delete t.clipRule,t)))))),c=1===h.length?h[0]:new Dr(h),l=St(r,c.calcTransformMatrix());c.clipPath&&await this.resolveClipPath(c,o,n.getAttribute("clip-path")?o:void 0);const{scaleX:u,scaleY:d,angle:g,skewX:f,translateX:p,translateY:m}=kt(l);c.set({flipX:!1,flipY:!1}),c.set({scaleX:u,scaleY:d,angle:g,skewX:f,skewY:0}),c.setPositionByOrigin(new ot(p,m),D,D),t.clipPath=c}else delete t.clipPath}}const na=t=>Ue.test(Ko(t)),oa=()=>({objects:[],elements:[],options:{},allElements:[]});async function aa(t,e){let{crossOrigin:s,signal:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r&&r.aborted)return h("log",new l("parseSVGDocument")),oa();const n=t.documentElement;!function(t){const e=Qo(t,["use","svg:use"]),s=["x","y","xlink:href","href","transform"];for(const i of e){const e=i.attributes,r={};for(const t of e)t.value&&(r[t.name]=t.value);const n=(r["xlink:href"]||r.href||"").slice(1);if(""===n)return;const o=t.getElementById(n);if(null===o)return;let a=o.cloneNode(!0);const h=a.attributes,c={};for(const t of h)t.value&&(c[t.name]=t.value);const{x:l=0,y:u=0,transform:d=""}=r,g="".concat(d," ").concat(c.transform||""," translate(").concat(l,", ").concat(u,")");if(qo(a),/^svg$/i.test(a.nodeName)){const t=a.ownerDocument.createElementNS(Ve,"g");Object.entries(c).forEach((e=>{let[s,i]=e;return t.setAttributeNS(Ve,s,i)})),t.append(...a.childNodes),a=t}for(const t of e){if(!t)continue;const{name:e,value:i}=t;if(!s.includes(e))if("style"===e){const t={};hr(i,t),Object.entries(c).forEach((e=>{let[s,i]=e;t[s]=i})),hr(c.style||"",t);const s=Object.entries(t).map((t=>t.join(":"))).join(";");a.setAttribute(e,s)}else!c[e]&&a.setAttribute(e,i)}a.setAttribute("transform",g),a.setAttribute("instantiated_by_use","1"),a.removeAttribute("id"),i.parentNode.replaceChild(a,i)}}(t);const o=Array.from(n.getElementsByTagName("*")),a=i(i({},qo(n)),{},{crossOrigin:s,signal:r}),c=o.filter((t=>(qo(t),na(t)&&!function(t){let e=t;for(;e&&(e=e.parentElement);)if(e&&e.nodeName&&Jo.test(Ko(e))&&!e.getAttribute("instantiated_by_use"))return!0;return!1}(t))));if(!c||c&&!c.length)return i(i({},oa()),{},{options:a,allElements:o});const u={};o.filter((t=>"clipPath"===Ko(t))).forEach((t=>{t.setAttribute("originalTransform",t.getAttribute("transform")||"");const e=t.getAttribute("id");u[e]=Array.from(t.getElementsByTagName("*")).filter((t=>na(t)))}));const d=new ra(c,a,e,t,u);return{objects:await d.parse(),elements:c,options:a,allElements:o}}const ha=W,ca=t=>function(e,s,i){const{points:r,pathOffset:n}=i;return new ot(r[t]).subtract(n).transform(St(i.getViewportTransform(),i.calcTransformMatrix()))},la=(t,e,s,i)=>{const{target:r,pointIndex:n}=e,o=r,a=Se(new ot(s,i),void 0,o.calcOwnMatrix());return o.points[n]=a.add(o.pathOffset),o.setDimensions(),!0},ua=(t,e)=>function(s,r,n,o){const a=r.target,h=new ot(a.points[(t>0?t:a.points.length)-1]),c=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()),l=e(s,i(i({},r),{},{pointIndex:t}),n,o),u=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()).subtract(c);return a.left-=u.x,a.top-=u.y,l},da=t=>Xs(ha,ua(t,la));const ga=(t,e,s)=>{const{path:i,pathOffset:r}=t,n=i[e];return new ot(n[s]-r.x,n[s+1]-r.y).transform(St(t.getViewportTransform(),t.calcTransformMatrix()))};function fa(t,e,s){const{commandIndex:i,pointIndex:r}=this;return ga(s,i,r)}function pa(t,e,s,r){const{target:n}=e,{commandIndex:o,pointIndex:a}=this,h=((t,e,s,i,r)=>{const{path:n,pathOffset:o}=t,a=n[(i>0?i:n.length)-1],h=new ot(a[r],a[r+1]),c=h.subtract(o).transform(t.calcOwnMatrix()),l=Se(new ot(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})(n,s,r,o,a);return ke(this.actionName,i(i({},Fe(t,e,s,r)),{},{commandIndex:o,pointIndex:a})),h}class ma extends zs{constructor(t){super(t)}render(t,e,s,r,n){const o=i(i({},r),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,s,o,n)}}class va extends ma{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=ga(r,h,c);if("Q"===l){const i=ga(r,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,s)}else t.moveTo(e,s);t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,s,i,r)}}const ya=(t,e,s,r,n,o)=>new(s?va:ma)(i(i({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:fa,actionHandler:pa,connectToCommandIndex:n,connectToPointIndex:o},r),s?r.controlPointStyle:r.pointStyle));var _a=Object.freeze({__proto__:null,changeWidth:Ws,createObjectDefaultControls:gi,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)]=ya(r,t.length-2,!1,e)),n){case"C":s["c_".concat(r,"_C_CP_1")]=ya(r,1,!0,e,r-1,(t=>"C"===t?5:"Q"===t?3:1)(i)),s["c_".concat(r,"_C_CP_2")]=ya(r,3,!0,e,r,5);break;case"Q":s["c_".concat(r,"_Q_CP_1")]=ya(r,1,!0,e,r,3)}i=n})),s},createPolyActionHandler:da,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s={};for(let r=0;r<("number"==typeof t?t:t.points.length);r++)s["p".concat(r)]=new zs(i({actionName:ha,positionHandler:ca(r),actionHandler:da(r)},e));return s},createPolyPositionHandler:ca,createResizeControls:fi,createTextboxDefaultControls:pi,dragHandler:Ie,factoryPolyActionHandler:ua,getLocalPoint:Re,polyActionHandler:la,renderCircleControl:Vs,renderSquareControl:Gs,rotationStyleHandler:Hs,rotationWithSnapping:Ns,scaleCursorStyleHandler:Js,scaleOrSkewActionName:ci,scaleSkewCursorStyleHandler:li,scalingEqually:Zs,scalingX:$s,scalingXOrSkewingY:ui,scalingY:ti,scalingYOrSkewingX:di,skewCursorStyleHandler:ri,skewHandlerX:oi,skewHandlerY:ai,wrapWithFireEvent:Xs,wrapWithFixedAnchor:Ys});const xa=t=>void 0!==t.webgl,Ca="precision highp float",ba="\n ".concat(Ca,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),wa=["type"],Sa=["type"],Ta=new RegExp(Ca,"g");class Oa{get type(){return this.constructor.type}constructor(){let t=r(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},wa);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return ba}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"}}=p();"highp"!==i&&(e=e.replace(Ta,Ca.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 c("Vertex, fragment shader or program creation error");if(t.shaderSource(r,s),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new c("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 c("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 c('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;r1){const s=t.destinationWidth,i=t.destinationHeight;t.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){xa(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=vt({width:e,height:s});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return i({type:this.type},t.reduce(((t,e)=>(t[e]=this[e],t)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(r(t,Sa))}}e(Oa,"type","BaseFilter"),e(Oa,"uniformLocations",[]);const ka={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 Da extends Oa{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(ka[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t;const s=new Ut(this.color).getSource(),i=this.alpha,r=s[0]*i,n=s[1]*i,o=s[2]*i,a=1-i;for(let t=0;tnew this(i(i({},o),{},{image:t}))))}}e(Ea,"type","BlendImage"),e(Ea,"defaults",{mode:"multiply",alpha:1}),e(Ea,"uniformLocations",["uTransformMatrix","uImage"]),tt.setClass(Ea);class Aa extends Oa{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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n "}applyTo(t){xa(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){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:s,filterBackend:{resources:i}}=t;const{width:r,height:n}=s;i.blurLayer1||(i.blurLayer1=pt(),i.blurLayer2=pt());const o=i.blurLayer1,a=i.blurLayer2;o.width===r&&o.height===n||(a.width=o.width=r,a.height=o.height=n);const h=o.getContext("2d"),c=a.getContext("2d"),l=15,u=.06*this.blur*.5;let d,g,f,p;for(h.putImageData(s,0,0),c.clearRect(0,0,r,n),p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*r+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,f,d),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);for(p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*n+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,d,f),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);e.drawImage(o,0,0);const m=e.getImageData(0,0,o.width,o.height);return h.globalAlpha=1,h.clearRect(0,0,o.width,o.height),m}sendUniformData(t,e){const s=this.chooseRightDelta();t.uniform2fv(e.uDelta,s)}isNeutralState(){return 0===this.blur}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const s=t*this.blur*.12;return this.horizontal?e[0]=s:e[1]=s,e}}e(Aa,"type","Blur"),e(Aa,"defaults",{blur:0}),e(Aa,"uniformLocations",["uDelta"]),tt.setClass(Aa);class ja extends Oa{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 t=0;t0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){xa(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((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=>tt.getClass(t.type).fromObject(t,e)))).then((t=>new this({subFilters:t})))}}e(za,"type","Composed"),tt.setClass(za);class Ha extends Oa{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 t=0;t=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 i(i({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}e(Ua,"type","Convolute"),e(Ua,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),e(Ua,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tt.setClass(Ua);const qa="Gamma";class Ka extends Oa{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 t=0;t<256;t++)o.r[t]=255*Math.pow(t/255,i),o.g[t]=255*Math.pow(t/255,r),o.b[t]=255*Math.pow(t/255,n);for(let t=0;tr[0]&&i>r[1]&&o>r[2]&&s"\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){xa(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=pt());const m=u.sliceByTwo;(m.width<1.5*e||m.height=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++y1&&n<-1||(l=2*n*n*n-3*n*n+1,l>0&&(s=4*(t+i*e),v+=l*c[s+3],g+=l,c[s+3]<255&&(l=l*c[s+3]/250),f+=l*c[s],p+=l*c[s+1],m+=l*c[s+2],d+=l))}}u[r]=f/d,u[r+1]=p/d,u[r+2]=m/d,u[r+3]=v/g}return l}}e(rh,"type","Resize"),e(rh,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),e(rh,"uniformLocations",["uDelta","uTaps"]),tt.setClass(rh);class nh extends Oa{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 t=0;t{const s=vt({width:t,height:e}),i=pt().getContext("webgl"),r={imageBuffer:new ArrayBuffer(t*e*4)},n={destinationWidth:t,destinationHeight:e,targetCanvas:s};let o;o=v().performance.now(),Wo.prototype.copyGLTo2D.call(r,i,n);const a=v().performance.now()-o;o=v().performance.now(),Wo.prototype.copyGLTo2DPutImageData.call(r,i,n);return a>v().performance.now()-o},t.isWebGLPipelineState=xa,t.loadSVGFromString=function(t,e,s){return aa((new(v().DOMParser)).parseFromString(t.trim(),"text/xml"),e,s)},t.loadSVGFromURL=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((e,i)=>{hn(t.replace(/^\n\s*/,"").trim(),{onComplete:t=>{const s=t.responseXML;s&&e(s),i()},signal:s.signal})})).then((t=>aa(t,e,s))).catch((()=>oa()))},t.parseAttributes=ur,t.parseFontDeclaration=ar,t.parsePointsAttribute=$n,t.parseSVGDocument=aa,t.parseStyleAttribute=cr,t.parseTransformAttribute=nr,t.runningAnimations=et,t.setEnv=t=>{f=t},t.setFilterBackend=function(t){Vo=t},t.util=ln,t.version=x})); //# sourceMappingURL=index.min.js.map diff --git a/dist/index.min.js.map b/dist/index.min.js.map index fd647b13375..2858a67122a 100644 --- a/dist/index.min.js.map +++ b/dist/index.min.js.map @@ -1 +1 @@ -{"version":3,"file":"index.min.js","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/util.ts","../src/color/Color.ts","../src/color/constants.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/findRight.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/elementMatchesRule.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/parseStyleObject.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/parser/getGlobalStylesForElement.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/util/misc/rotatePoint.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/CanvasOptions.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/parseUseDirectives.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/Blur.ts","../src/filters/shaders/blur.ts","../src/filters/Brightness.ts","../src/filters/shaders/brightness.ts","../src/filters/ColorMatrix.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/Contrast.ts","../src/filters/shaders/constrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/Invert.ts","../src/filters/shaders/invert.ts","../src/filters/Noise.ts","../src/filters/shaders/noise.ts","../src/filters/Pixelate.ts","../src/filters/shaders/pixelate.ts","../src/filters/RemoveColor.ts","../src/filters/shaders/removeColor.ts","../src/filters/Resize.ts","../src/filters/Saturation.ts","../src/filters/shaders/saturation.ts","../src/filters/Vibrance.ts","../src/filters/shaders/vibrance.ts","../src/brushes/CircleBrush.ts","../src/brushes/PatternBrush.ts","../src/brushes/SprayBrush.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport {\n isFiller,\n isSerializableFiller,\n isTextObject,\n} from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: neededX + ALIASING_LIMIT,\n height: neededY + ALIASING_LIMIT,\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n minCacheSize = config.minCacheSideLimit,\n width = dims.width,\n height = dims.height,\n zoomX = dims.zoomX,\n zoomY = dims.zoomY,\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n let drawingWidth,\n drawingHeight,\n shouldRedraw = dimensionsChanged || zoomChanged,\n additionalWidth = 0,\n additionalHeight = 0,\n shouldResizeCanvas = false;\n\n if (dimensionsChanged) {\n const canvasWidth = (this._cacheCanvas as HTMLCanvasElement).width,\n canvasHeight = (this._cacheCanvas as HTMLCanvasElement).height,\n sizeGrowing = width > canvasWidth || height > canvasHeight,\n sizeShrinking =\n (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) &&\n canvasWidth > minCacheSize &&\n canvasHeight > minCacheSize;\n shouldResizeCanvas = sizeGrowing || sizeShrinking;\n if (\n sizeGrowing &&\n !dims.capped &&\n (width > minCacheSize || height > minCacheSize)\n ) {\n additionalWidth = width * 0.1;\n additionalHeight = height * 0.1;\n }\n }\n if (isTextObject(this) && this.path) {\n shouldRedraw = true;\n shouldResizeCanvas = true;\n // IMHO in those lines we are using zoomX and zoomY not the this version.\n additionalWidth += this.getHeightOfLine(0) * this.zoomX!;\n additionalHeight += this.getHeightOfLine(0) * this.zoomY!;\n }\n if (shouldRedraw) {\n if (shouldResizeCanvas) {\n canvas.width = Math.ceil(width + additionalWidth);\n canvas.height = Math.ceil(height + additionalHeight);\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n drawingWidth = dims.x / 2;\n drawingHeight = dims.y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = undefined;\n this._pointer = undefined;\n this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n *\n * @param {string} property The property to compare between characters and text.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n // @ts-expect-error conspiracy theory of TS\n this[property as keyof this] = stylePropertyValue;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n // @ts-expect-error readonly\n ...pick(this, (this.constructor as typeof StyledText)._styleProperties),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n // @ts-expect-error legacy method calling pattern\n this[keyMap[e.keyCode]](e);\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapDown[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapUp[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\n\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n // @ts-expect-error in reality it is an IText instance\n this.draggableTextDelegate = new DraggableTextDelegate(this);\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n // @ts-expect-error is this a bug? should this be naturalWidth? or is this the pipeline state?\n (source as HTMLImageElement).originalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n // @ts-expect-error is this a bug? should this be naturalHeight? or is this the pipeline state?\n (source as HTMLImageElement).originalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const tr = source[0] * this.alpha;\n const tg = source[1] * this.alpha;\n const tb = source[2] * this.alpha;\n const alpha1 = 1 - this.alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n break;\n case 'screen':\n data[i] = 255 - ((255 - r) * (255 - tr)) / 255;\n data[i + 1] = 255 - ((255 - g) * (255 - tg)) / 255;\n data[i + 2] = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n data[i] = r + tr;\n data[i + 1] = g + tg;\n data[i + 2] = b + tb;\n break;\n case 'difference':\n data[i] = Math.abs(r - tr);\n data[i + 1] = Math.abs(g - tg);\n data[i + 2] = Math.abs(b - tb);\n break;\n case 'subtract':\n data[i] = r - tr;\n data[i + 1] = g - tg;\n data[i + 2] = b - tb;\n break;\n case 'darken':\n data[i] = Math.min(r, tr);\n data[i + 1] = Math.min(g, tg);\n data[i + 2] = Math.min(b, tb);\n break;\n case 'lighten':\n data[i] = Math.max(r, tr);\n data[i + 1] = Math.max(g, tg);\n data[i + 2] = Math.max(b, tb);\n break;\n case 'overlay':\n data[i] =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n data[i + 1] =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n data[i + 2] =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n data[i] = tr + r - (2 * tr * r) / 255;\n data[i + 1] = tg + g - (2 * tg * g) / 255;\n data[i + 2] = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n data[i] = tr + r * alpha1;\n data[i + 1] = tg + g * alpha1;\n data[i + 2] = tb + b * alpha1;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = data[i] + brightness;\n data[i + 1] = data[i + 1] + brightness;\n data[i + 2] = data[i + 2] + brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\ntype ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n if (colorsOnly) {\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n } else {\n const a = data[i + 3];\n data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255;\n data[i + 2] =\n r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255;\n data[i + 3] =\n r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject() {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","export const fragmentSource = `\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 }`;\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n //@ts-expect-error TS wants matrix to be exported.\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<'Composed', ComposedOwnProps> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n //@ts-expect-error TS doesn't like this toObject\n toObject(): {\n type: 'Composed';\n subFilters: ReturnType['toObject']>[];\n } {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = `\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 }`;\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n switch (this.mode) {\n case 'average':\n value = (data[i] + data[i + 1] + data[i + 2]) / 3;\n break;\n case 'lightness':\n value =\n (Math.min(data[i], data[i + 1], data[i + 2]) +\n Math.max(data[i], data[i + 1], data[i + 2])) /\n 2;\n break;\n case 'luminosity':\n value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2];\n break;\n }\n\n data[i] = value;\n data[i + 1] = value;\n data[i + 2] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport { ColorMatrix } from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];\n this.matrix[0] = cosine + OneMinusCos / 3;\n this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[6] = cosine + aThird * OneMinusCos;\n this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[12] = cosine + aThird * OneMinusCos;\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n //@ts-expect-error TS and classes with different methods\n toObject(): { type: 'HueRotation'; rotation: number } {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentSource = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","export const fragmentShader = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n data[i] += max !== data[i] ? (max - data[i]) * adjust : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n const avg = (data[i] + data[i + 1] + data[i + 2]) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== data[i] ? (max - data[i]) * amt : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n","export const fragmentSource = `\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`;\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n"],"names":["BaseConfiguration","constructor","_defineProperty","this","window","devicePixelRatio","config","super","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","env","setEnv","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","VERSION","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","classRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","runningAnimations","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","value","idx","cos","angle","abs","sin","angleSlice","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","element","createElement","createImage","createCanvasElementFor","newCanvas","toDataURL","canvasEl","format","quality","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","parseAngletoDegrees","fromHex","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","parseUnit","fontSize","unit","exec","dpi","DPI","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","align","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","colorValue","opacityValue","inlineStyle","toLive","opacity","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","_renderText","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","getElementOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","drawImage","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","version","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getPointer","event","scroll","_evt","touchProp","changedTouches","getTouchInfo","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","addTransformToObject","applyTransformToObject","calcOwnMatrix","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","sendPointToPlane","to","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","control","cornerAngle","getTotalAngle","getLocalPoint","corner","controls","padding","localPoint","getRelativeCenterPoint","translateToGivenOrigin","normalizePoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","Shadow","parseShadow","shadowStr","blur","replace","fBoxX","fBoxY","affectStroke","nonScaling","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","inverted","centeredRotation","centeredScaling","dirty","normalize","c","asin","elastic","defaultEasing","easeOutBounce","easeInBounce","easeInCirc","easeInCubic","easeInElastic","normA","normS","normP","easeInExpo","easeInOutBounce","easeInOutCirc","easeInOutCubic","easeInOutElastic","normC","easeInOutExpo","easeInOutQuad","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInQuad","easeInQuart","easeInQuint","easeInSine","easeOutCirc","easeOutCubic","easeOutElastic","easeOutExpo","easeOutQuad","easeOutQuart","easeOutQuint","easeOutSine","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","animate","isArrayAnimation","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersectsWithObject","intersection","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","w","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","minCacheSize","dimensionsChanged","zoomChanged","drawingWidth","drawingHeight","shouldRedraw","additionalWidth","additionalHeight","shouldResizeCanvas","canvasWidth","canvasHeight","sizeGrowing","getHeightOfLine","ceil","setTransform","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeWidth","changeObjectWidth","strokePadding","oldWidth","newWidth","renderCircleControl","styleOverride","xSize","sizeX","cornerSize","ySize","sizeY","transparentCorners","cornerStrokeColor","myLeft","myTop","cornerColor","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","cornerStyle","rotationStyleHandler","lockRotation","rotationWithSnapping","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","signX","signY","gestureScale","distance","original","oldScaleX","oldScaleY","scalingEqually","scaleObjectFromCorner","scalingX","scaleObjectX","scalingY","scaleObjectY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewHandler","axis","originKey","lockSkewingKey","skewKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingSide","finalHandler","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewObject","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","noScaleCache","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","hasControls","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","touchCornerSize","fn","selectionBackgroundColor","_activeObject","wh","strokeBorders","_drawBorders","borderColor","borderDashArray","drawControlsConnectingLines","_renderControls","hasBorders","styleOptions","shouldDrawBorders","shouldDrawControls","borderScaleFactor","isMoving","borderOpacityWhenMoving","drawBorders","forActiveSelection","shouldStroke","cornerDashArray","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","lockMovementX","lockMovementY","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","isTransparent","tolerance","getImageData","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","findIndexRight","cloneStyles","newObj","keyInner","escapeXml","string","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","charAt","next","prev","firstLetterOnly","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","elementMatchesRule","selectors","parentMatching","firstMatching","parentElement","doesSomeParentMatch","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleString","chunk","parseStyleAttribute","parseStyleObject","colorAttributesMap","parseAttributes","attributes","cssRules","parentFontSize","ownAttributes","rule","getGlobalStylesForElement","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","colorAttr","setStrokeFillOpacity","RECT_PROPS","Rect","_initRxRy","rx","ry","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","_context$x","_context$y","layoutObjects","layoutObject","_","bubblingContext","NoopLayoutManager","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","subTargetCheck","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","interactive","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","calcVectorAngle","ux","uy","vx","vy","ta","tb","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","large","sweep","tx","ty","segsNorm","arcToSegments","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","dtheta","segments","mDelta","th3","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","CB2","c3","CB3","c4","CB4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","tempInfo","totalLength","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","p2","multSignX","multSignY","manyPoints","midPoint","joinPath","pathData","setStyle","elementStyle","setProperty","getRandomInt","random","request","xhr","removeListener","ontimeout","onreadystatechange","readyState","open","send","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","_assignTransformMatrixProps","cropX","cropY","offsetLeft","offsetTop","_newCanvas$getContext","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","commonAttributes","groupSVGElements","mergeClipPaths","_b$group","removeTransformFromObject","finalTransform","rotatePoint","transformPath","pathOffset","pathSegment","newSegment","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","selection","_drawSelection","renderTop","setTargetFindTolerance","targetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","selectionKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","alreadySelected","_control$getActionHan","getScenePoint","getActionFromCorner","altKey","centeredKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","selectionLineWidth","minX","minY","maxX","maxY","selectionColor","selectionBorderColor","selectionDashArray","findTarget","skipTargetFind","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","originalValues","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_transformObject","_fireOverOutEvents","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","newActiveSelection","point1","point2","collectedObjects","klass","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","getValue","parseCoords","valuesToConvert","finalValue","propValue","convertPercentUnitsToValues","parseLinearCoords","parseRadialCoords","Gradient","addColorStop","colorStop","preTransform","sort","_renderPathCommands","needsSwap","minRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","cDistance","lastPoint","adjustedDistance","newPoints","decimate","isEmptySVGPath","CIRCLE_PROPS","Circle","setRadius","startAngle","endAngle","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","Triangle","widthBy2","heightBy2","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","letterCount","stylePropertyValue","stylesCount","allStyleObjectPropertiesMatch","graphemeCount","styleObject","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","svgColor","createSVGRect","measuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","__charBounds","kernedWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","leftOffset","_getLeftOffset","lineTopOffset","_getTopOffset","heightOfLine","lineLeftOffset","_getLineLeftOffset","drawStart","currentColor","boxWidth","boxStart","lastColor","getValueOfPropertyAt","charBox","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","getMeasuringContext","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","isJustify","shortCut","isLtr","currentDirection","actualStyle","nextStyle","timeToRender","drawingLeft","charsToRender","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","currentDecoration","currentFill","lastDecoration","lastFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","textDecoration","restOfOptions","textContent","textHeightScaleFactor","scaledDiff","textHeight","offX","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","textBgRects","textSpans","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","_getSVGLineTopOffset","lastHeight","useWhiteSpace","decoration","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","removeFrom","removeTo","charDiff","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","bound","widthBeforeCursor","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","getUpCursorOffset","textBeforeCursor","charWidth","foundMatch","widthOfCharsOnLine","indexOnLine","leftEdge","rightEdge","offsetFromLeftEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderSelection","renderCursor","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","Textbox","dynamicMinWidth","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","splitByGrapheme","isWrapping","nextOffset","nextLineIndex","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","_wordJoiners","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","minWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","ActiveSelection","multiSelectionStacking","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","pipelineState","imageData","originalEl","originalImageData","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","dWidth","dHeight","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","backend","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","imageSmoothing","getSvgSrc","origFill","filtered","srcFromAttribute","setSrc","minimumScale","minimumScaleTrigger","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","getMultipleNodes","nodeNames","nodeList","nodeArray","getElementsByTagNameNS","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","cloneNode","tagArray","getCSSRules","allRules","styleContents","ruleObj","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","gradientDefs","elList","getGradientDefs","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","async","parseSVGDocument","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","parseUseDirectives","descendants","hasInvalidAncestor","localClipPaths","elementParser","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","createPolyActionHandler","calcPathPointPosition","pathObject","commandIndex","pathPositionHandler","pathActionHandler","movePathPoint","anchorCommand","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","previousCommandType","indexFromPrevCommand","isWebGLPipelineState","highPsourceCode","identityFragmentShader","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexSource","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","BlendColor","mode","tg","alpha1","uniform4fv","uColor","mask","BlendImage","image","TEXTURE1","calculateMatrix","resources","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","filterOptions","enlivedImage","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","Brightness","brightness","uBrightness","ColorMatrix","colorsOnly","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","Contrast","contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","Convolute","opaque","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","Gamma","gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","Grayscale","uMode","HueRotation","rotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","Invert","invert","uInvert","uAlpha","Noise","noise","rand","uNoise","uSeed","Pixelate","blocksize","_i","_j","uBlocksize","RemoveColor","lowC","highC","uLow","uHigh","useAlpha","Resize","uTaps","taps","getFilterWindow","tempScale","lanczosLobes","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","resizeType","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","srcData","destImg","destData","lanczos","ratioX","ratioY","rcpRatioX","rcpRatioY","range2X","range2Y","cacheLanc","icenter","process","u","weight","fX","fY","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","Saturation","adjust","saturation","uSaturation","Vibrance","vibrance","amt","uVibrance","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","getPatternSrc","patternCanvas","patternCtx","dotWidth","getPattern","pattern","topLeft","sprayChunks","sprayChunk","addSprayChunk","renderChunck","rects","chunck","rect","optimizeOverlapping","uniqueRects","uniqueRectsArray","getUniqueRects","sprayChunck","density","dotWidthVariance","randomOpacity","isPutImageFaster","testContext","ArrayBuffer","testPipelineState","performance","now","drawImageTime","parseFromString","xml","responseXML","parsedDoc"],"mappings":"usDAEA,MAAMA,EAAkBC,WAAAA,GACtBC,mCAc4B,GAE5BA,aAGM,IAENA,EAAAC,KAAA,mBAKoB,oBAAXC,OAAyBA,OAAOC,iBAAmB,GAE5DH,4BAMqB,SAErBA,2BAMoB,MAEpBA,2BAMoB,KAEpBA,gCAQwB,GAExBA,4BAQoB,GAEpBA,qBAUc,MAEdA,8BAOsB,GAEtBA,8BAQsB,GAEtBA,EAAAC,KAAA,YAIwE,CAAA,GAExED,6BAKsB,EAAC,EA8CZI,MAAAA,EAAS,IA3Cf,cAA4BN,EACjCC,WAAAA,CAAYK,GACVC,QACAJ,KAAKK,UAAUF,EACjB,CAEAE,SAAAA,GAAuC,IAA7BF,EAAsBG,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EACjCG,OAAOC,OAAOV,KAAMG,EACtB,CAKAQ,QAAAA,GAEE,IADAC,EAAiEN,UAAAC,OA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AAA,EAG5B,OAAO,IAAI+W,SAAkB,CAACC,EAASC,KASrC0qD,GAAQ/qD,EAAImqB,QAAQ,SAAU,IAAI5Z,OAAQ,CACxCwd,WATkBrwB,IAClB,MAAMoxG,EAAMpxG,EAAEqxG,YACVD,GACF1uG,EAAQ0uG,GAEVzuG,GAAQ,EAKRJ,OAAQhV,EAAQgV,QAChB,IAEDoB,MAAM2tG,GAAc3X,GAAiB2X,EAAWhuG,EAAS/V,KACzDsW,OAAM,IAEE21F,MAEb,uL5MjBuB7iG,IACrBtH,EAAMsH,CAAK,qBqJMN,SAA0B67F,GAC/BtF,GAAgBsF,CAClB"} \ No newline at end of file +{"version":3,"file":"index.min.js","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/util.ts","../src/color/Color.ts","../src/color/constants.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/findRight.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/elementMatchesRule.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/parseStyleObject.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/parser/getGlobalStylesForElement.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/util/misc/rotatePoint.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/CanvasOptions.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/parseUseDirectives.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/Blur.ts","../src/filters/shaders/blur.ts","../src/filters/Brightness.ts","../src/filters/shaders/brightness.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/Contrast.ts","../src/filters/shaders/constrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/Invert.ts","../src/filters/shaders/invert.ts","../src/filters/Noise.ts","../src/filters/shaders/noise.ts","../src/filters/Pixelate.ts","../src/filters/shaders/pixelate.ts","../src/filters/RemoveColor.ts","../src/filters/shaders/removeColor.ts","../src/filters/Resize.ts","../src/filters/Saturation.ts","../src/filters/shaders/saturation.ts","../src/filters/Vibrance.ts","../src/filters/shaders/vibrance.ts","../src/brushes/CircleBrush.ts","../src/brushes/PatternBrush.ts","../src/brushes/SprayBrush.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n color = color.toLowerCase();\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport { isFiller, isSerializableFiller } from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: Math.ceil(neededX + ALIASING_LIMIT),\n height: Math.ceil(neededY + ALIASING_LIMIT),\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n { width, height, zoomX, zoomY, x, y } = this._limitCacheSize(\n this._getCacheCanvasDimensions(),\n ),\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n const shouldRedraw = dimensionsChanged || zoomChanged;\n\n if (shouldRedraw) {\n if (width !== canvas.width || height !== canvas.height) {\n canvas.width = width;\n canvas.height = height;\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n const drawingWidth = x / 2;\n const drawingHeight = y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = this._pointer = this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n this[property as keyof this] = stylePropertyValue as any;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n ...pick(\n this,\n (this.constructor as typeof StyledText)\n ._styleProperties as (keyof this)[],\n ),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n (this[keyMap[e.keyCode] as keyof this] as (arg: KeyboardEvent) => void)(\n e,\n );\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapDown[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapUp[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport type { IText } from './IText';\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n this.draggableTextDelegate = new DraggableTextDelegate(\n this as unknown as IText,\n );\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n (source as HTMLImageElement).naturalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n (source as HTMLImageElement).naturalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n SerializedProps extends Record = OwnProps,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & SerializedProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof SerializedProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as SerializedProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const alpha = this.alpha;\n const tr = source[0] * alpha;\n const tg = source[1] * alpha;\n const tb = source[2] * alpha;\n const alpha1 = 1 - alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n let oR, oG, oB;\n switch (this.mode) {\n case 'multiply':\n oR = (r * tr) / 255;\n oG = (g * tg) / 255;\n oB = (b * tb) / 255;\n break;\n case 'screen':\n oR = 255 - ((255 - r) * (255 - tr)) / 255;\n oG = 255 - ((255 - g) * (255 - tg)) / 255;\n oB = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n oR = r + tr;\n oG = g + tg;\n oB = b + tb;\n break;\n case 'difference':\n oR = Math.abs(r - tr);\n oG = Math.abs(g - tg);\n oB = Math.abs(b - tb);\n break;\n case 'subtract':\n oR = r - tr;\n oG = g - tg;\n oB = b - tb;\n break;\n case 'darken':\n oR = Math.min(r, tr);\n oG = Math.min(g, tg);\n oB = Math.min(b, tb);\n break;\n case 'lighten':\n oR = Math.max(r, tr);\n oG = Math.max(g, tg);\n oB = Math.max(b, tb);\n break;\n case 'overlay':\n oR =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n oG =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n oB =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n oR = tr + r - (2 * tr * r) / 255;\n oG = tg + g - (2 * tg * g) / 255;\n oB = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n oR = tr + r * alpha1;\n oG = tg + g * alpha1;\n oB = tb + b * alpha1;\n }\n data[i] = oR;\n data[i + 1] = oG;\n data[i + 2] = oB;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] += brightness;\n data[i + 1] += brightness;\n data[i + 2] += brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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`;\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\nexport type ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n SerializedProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n if (!colorsOnly) {\n const a = data[i + 3];\n data[i] += a * m[3];\n data[i + 1] += a * m[8];\n data[i + 2] += a * m[13];\n data[i + 3] += a * m[18];\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject(): { type: Name } & SerializedProps {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix<\n typeof key,\n FixedFiltersOwnProps,\n FixedFiltersOwnProps\n > {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\ntype ComposedSerializedProps = {\n subFilters: Record[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<\n 'Composed',\n ComposedOwnProps,\n ComposedSerializedProps\n> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n toObject() {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = `\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 }`;\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n switch (this.mode) {\n case 'average':\n value = (r + g + b) / 3;\n break;\n case 'lightness':\n value = (Math.min(r, g, b) + Math.max(r, g, b)) / 2;\n break;\n case 'luminosity':\n value = 0.21 * r + 0.72 * g + 0.07 * b;\n break;\n }\n\n data[i + 2] = data[i + 1] = data[i] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport {\n ColorMatrix,\n type ColorMatrixOwnProps,\n colorMatrixDefaultValues,\n} from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = ColorMatrixOwnProps & {\n rotation: number;\n};\n\nexport type HueRotationSerializedProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n ...colorMatrixDefaultValues,\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps,\n HueRotationSerializedProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [\n cosine + OneMinusCos / 3,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n aThird * OneMinusCos - aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n 0,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n ];\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n toObject() {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentSource = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","export const fragmentShader = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n data[i] += max !== r ? (max - r) * adjust : 0;\n data[i + 1] += max !== g ? (max - g) * adjust : 0;\n data[i + 2] += max !== b ? (max - b) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n const avg = (r + g + b) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== r ? (max - r) * amt : 0;\n data[i + 1] += max !== g ? (max - g) * amt : 0;\n data[i + 2] += max !== b ? (max - b) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n","export const fragmentSource = `\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`;\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n"],"names":["BaseConfiguration","constructor","_defineProperty","this","window","devicePixelRatio","config","super","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","env","setEnv","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","VERSION","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","classRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","runningAnimations","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","value","idx","cos","angle","abs","sin","angleSlice","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","element","createElement","createImage","createCanvasElementFor","newCanvas","toDataURL","canvasEl","format","quality","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","parseAngletoDegrees","fromHex","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","parseUnit","fontSize","unit","exec","dpi","DPI","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","align","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","colorValue","opacityValue","inlineStyle","toLive","opacity","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","getElementOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","drawImage","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","version","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","_renderText","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getPointer","event","scroll","_evt","touchProp","changedTouches","getTouchInfo","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","addTransformToObject","applyTransformToObject","calcOwnMatrix","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","sendPointToPlane","to","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","control","cornerAngle","getTotalAngle","getLocalPoint","corner","controls","padding","localPoint","getRelativeCenterPoint","translateToGivenOrigin","normalizePoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","Shadow","parseShadow","shadowStr","blur","replace","fBoxX","fBoxY","affectStroke","nonScaling","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","inverted","centeredRotation","centeredScaling","dirty","normalize","c","asin","elastic","defaultEasing","easeOutBounce","easeInBounce","easeInCirc","easeInCubic","easeInElastic","normA","normS","normP","easeInExpo","easeInOutBounce","easeInOutCirc","easeInOutCubic","easeInOutElastic","normC","easeInOutExpo","easeInOutQuad","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInQuad","easeInQuart","easeInQuint","easeInSine","easeOutCirc","easeOutCubic","easeOutElastic","easeOutExpo","easeOutQuad","easeOutQuart","easeOutQuint","easeOutSine","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","animate","isArrayAnimation","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersectsWithObject","intersection","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","w","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","ceil","dimensionsChanged","zoomChanged","setTransform","drawingWidth","drawingHeight","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeWidth","changeObjectWidth","strokePadding","oldWidth","newWidth","renderCircleControl","styleOverride","xSize","sizeX","cornerSize","ySize","sizeY","transparentCorners","cornerStrokeColor","myLeft","myTop","cornerColor","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","cornerStyle","rotationStyleHandler","lockRotation","rotationWithSnapping","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","signX","signY","gestureScale","distance","original","oldScaleX","oldScaleY","scalingEqually","scaleObjectFromCorner","scalingX","scaleObjectX","scalingY","scaleObjectY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewHandler","axis","originKey","lockSkewingKey","skewKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingSide","finalHandler","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewObject","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","noScaleCache","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","hasControls","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","touchCornerSize","fn","selectionBackgroundColor","_activeObject","wh","strokeBorders","_drawBorders","borderColor","borderDashArray","drawControlsConnectingLines","_renderControls","hasBorders","styleOptions","shouldDrawBorders","shouldDrawControls","borderScaleFactor","isMoving","borderOpacityWhenMoving","drawBorders","forActiveSelection","shouldStroke","cornerDashArray","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","lockMovementX","lockMovementY","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","isTransparent","tolerance","getImageData","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","findIndexRight","cloneStyles","newObj","keyInner","escapeXml","string","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","charAt","next","prev","firstLetterOnly","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","elementMatchesRule","selectors","parentMatching","firstMatching","parentElement","doesSomeParentMatch","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleString","chunk","parseStyleAttribute","parseStyleObject","colorAttributesMap","parseAttributes","attributes","cssRules","parentFontSize","ownAttributes","rule","getGlobalStylesForElement","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","colorAttr","setStrokeFillOpacity","RECT_PROPS","Rect","_initRxRy","rx","ry","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","_context$x","_context$y","layoutObjects","layoutObject","_","bubblingContext","NoopLayoutManager","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","subTargetCheck","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","interactive","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","calcVectorAngle","ux","uy","vx","vy","ta","tb","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","large","sweep","tx","ty","segsNorm","arcToSegments","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","dtheta","segments","mDelta","th3","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","CB2","c3","CB3","c4","CB4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","tempInfo","totalLength","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","p2","multSignX","multSignY","manyPoints","midPoint","joinPath","pathData","setStyle","elementStyle","setProperty","getRandomInt","random","request","xhr","removeListener","ontimeout","onreadystatechange","readyState","open","send","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","_assignTransformMatrixProps","cropX","cropY","offsetLeft","offsetTop","_newCanvas$getContext","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","commonAttributes","groupSVGElements","mergeClipPaths","_b$group","removeTransformFromObject","finalTransform","rotatePoint","transformPath","pathOffset","pathSegment","newSegment","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","selection","_drawSelection","renderTop","setTargetFindTolerance","targetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","selectionKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","alreadySelected","_control$getActionHan","getScenePoint","getActionFromCorner","altKey","centeredKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","selectionLineWidth","minX","minY","maxX","maxY","selectionColor","selectionBorderColor","selectionDashArray","findTarget","skipTargetFind","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","originalValues","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_transformObject","_fireOverOutEvents","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","newActiveSelection","point1","point2","collectedObjects","klass","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","getValue","parseCoords","valuesToConvert","finalValue","propValue","convertPercentUnitsToValues","parseLinearCoords","parseRadialCoords","Gradient","addColorStop","colorStop","preTransform","sort","_renderPathCommands","needsSwap","minRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","cDistance","lastPoint","adjustedDistance","newPoints","decimate","isEmptySVGPath","CIRCLE_PROPS","Circle","setRadius","startAngle","endAngle","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","Triangle","widthBy2","heightBy2","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","letterCount","stylePropertyValue","stylesCount","allStyleObjectPropertiesMatch","graphemeCount","styleObject","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","svgColor","createSVGRect","measuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","__charBounds","kernedWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","leftOffset","_getLeftOffset","lineTopOffset","_getTopOffset","heightOfLine","getHeightOfLine","lineLeftOffset","_getLineLeftOffset","drawStart","currentColor","boxWidth","boxStart","lastColor","getValueOfPropertyAt","charBox","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","getMeasuringContext","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","isJustify","shortCut","isLtr","currentDirection","actualStyle","nextStyle","timeToRender","drawingLeft","charsToRender","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","currentDecoration","currentFill","lastDecoration","lastFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","textDecoration","restOfOptions","textContent","textHeightScaleFactor","scaledDiff","textHeight","offX","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","textBgRects","textSpans","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","_getSVGLineTopOffset","lastHeight","useWhiteSpace","decoration","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","removeFrom","removeTo","charDiff","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","bound","widthBeforeCursor","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","getUpCursorOffset","textBeforeCursor","charWidth","foundMatch","widthOfCharsOnLine","indexOnLine","leftEdge","rightEdge","offsetFromLeftEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderSelection","renderCursor","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","Textbox","dynamicMinWidth","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","splitByGrapheme","isWrapping","nextOffset","nextLineIndex","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","_wordJoiners","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","minWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","ActiveSelection","multiSelectionStacking","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","pipelineState","imageData","originalEl","originalImageData","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","dWidth","dHeight","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","backend","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","imageSmoothing","getSvgSrc","origFill","filtered","srcFromAttribute","setSrc","minimumScale","minimumScaleTrigger","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","getMultipleNodes","nodeNames","nodeList","nodeArray","getElementsByTagNameNS","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","cloneNode","tagArray","getCSSRules","allRules","styleContents","ruleObj","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","gradientDefs","elList","getGradientDefs","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","async","parseSVGDocument","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","parseUseDirectives","descendants","hasInvalidAncestor","localClipPaths","elementParser","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","createPolyActionHandler","calcPathPointPosition","pathObject","commandIndex","pathPositionHandler","pathActionHandler","movePathPoint","anchorCommand","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","previousCommandType","indexFromPrevCommand","isWebGLPipelineState","highPsourceCode","identityFragmentShader","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexSource","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","BlendColor","mode","tg","alpha1","oR","oG","oB","uniform4fv","uColor","mask","BlendImage","image","TEXTURE1","calculateMatrix","resources","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","filterOptions","enlivedImage","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","Brightness","brightness","uBrightness","colorMatrixDefaultValues","colorsOnly","ColorMatrix","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","Contrast","contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","Convolute","opaque","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","Gamma","gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","Grayscale","uMode","hueRotationDefaultValues","rotation","HueRotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","Invert","invert","uInvert","uAlpha","Noise","noise","rand","uNoise","uSeed","Pixelate","blocksize","_i","_j","uBlocksize","RemoveColor","lowC","highC","uLow","uHigh","useAlpha","Resize","uTaps","taps","getFilterWindow","tempScale","lanczosLobes","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","resizeType","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","srcData","destImg","destData","lanczos","ratioX","ratioY","rcpRatioX","rcpRatioY","range2X","range2Y","cacheLanc","icenter","process","u","weight","fX","fY","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","Saturation","adjust","saturation","uSaturation","Vibrance","vibrance","amt","uVibrance","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","getPatternSrc","patternCanvas","patternCtx","dotWidth","getPattern","pattern","topLeft","sprayChunks","sprayChunk","addSprayChunk","renderChunck","rects","chunck","rect","optimizeOverlapping","uniqueRects","uniqueRectsArray","getUniqueRects","sprayChunck","density","dotWidthVariance","randomOpacity","isPutImageFaster","testContext","ArrayBuffer","testPipelineState","performance","now","drawImageTime","parseFromString","xml","responseXML","parsedDoc"],"mappings":"usDAEA,MAAMA,EAAkBC,WAAAA,GACtBC,mCAc4B,GAE5BA,aAGM,IAENA,EAAAC,KAAA,mBAKoB,oBAAXC,OAAyBA,OAAOC,iBAAmB,GAE5DH,4BAMqB,SAErBA,2BAMoB,MAEpBA,2BAMoB,KAEpBA,gCAQwB,GAExBA,4BAQoB,GAEpBA,qBAUc,MAEdA,8BAOsB,GAEtBA,8BAQsB,GAEtBA,EAAAC,KAAA,YAIwE,CAAA,GAExED,6BAKsB,EAAC,EA8CZI,MAAAA,EAAS,IA3Cf,cAA4BN,EACjCC,WAAAA,CAAYK,GACVC,QACAJ,KAAKK,UAAUF,EACjB,CAEAE,SAAAA,GAAuC,IAA7BF,EAAsBG,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EACjCG,OAAOC,OAAOV,KAAMG,EACtB,CAKAQ,QAAAA,GAEE,IADAC,EAAiEN,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAEpEN,KAAKa,UAASC,EAAAA,EACT,CAAA,EAAAd,KAAKa,WACLD,EAEP,CAEAG,WAAAA,IAAiCT,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,IACtBU,SAASC,WACZjB,KAAKa,UAAUI,EAAW,GAErC,CAEAC,UAAAA,GACElB,KAAKa,UAAY,EACnB,CAEAM,eAAAA,CAA6CC,GAC3C,MAAMC,EAAW,IAAIxB,EACfM,GACJiB,aAAI,EAAJA,EAAME,QAAO,CAACC,EAAKC,KACjBD,EAAIC,GAAOH,EAASG,GACbD,IACN,CAAA,KAAYF,EACjBrB,KAAKK,UAAUF,EACjB,GChKWsB,EAAM,SACjBC,GAAkC,IAAAC,IAAAA,EAAArB,UAAA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,IACrBtH,EAAMsH,CAAK,qBqJMN,SAA0Bo7F,GAC/BtF,GAAgBsF,CAClB"} \ No newline at end of file diff --git a/dist/index.min.mjs b/dist/index.min.mjs index a182202c0b6..667760798b1 100644 --- a/dist/index.min.mjs +++ b/dist/index.min.mjs @@ -1,2 +1,2 @@ -function t(t,e,s){return(e=function(t){var e=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||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function e(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 s(s){for(var i=1;i=0)continue;s[i]=t[i]}return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i=0||{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function r(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class n{constructor(){t(this,"browserShadowBlurConstant",1),t(this,"DPI",96),t(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),t(this,"perfLimitSizeTotal",2097152),t(this,"maxCacheSideLimit",4096),t(this,"minCacheSideLimit",256),t(this,"disableStyleCopyPaste",!1),t(this,"enableGLFiltering",!0),t(this,"textureSize",4096),t(this,"forceGLPutImageData",!1),t(this,"cachesBoundsOfCurve",!1),t(this,"fontPaths",{}),t(this,"NUM_FRACTION_DIGITS",4)}}const o=new class extends n{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=s(s({},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 n,s=(null==t?void 0:t.reduce(((t,s)=>(t[s]=e[s],t)),{}))||e;this.configure(s)}},a=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis.testPrecision(e,t))),e.getExtension("WEBGL_lose_context").loseContext(),a("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const d={};let g;const f=t=>{g=t},p=()=>g||(g={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new u,dispose(){},copyPasteData:d}),m=()=>p().document,v=()=>p().window,y=()=>{var t;return Math.max(null!==(t=o.devicePixelRatio)&&void 0!==t?t:v().devicePixelRatio,1)};const _=new class{constructor(){t(this,"charWidthsCache",{}),t(this,"boundsOfCurveCache",{})}getFontCache(t){let{fontFamily:e,fontStyle:s,fontWeight:i}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});const r=this.charWidthsCache[e],n="".concat(s.toLowerCase(),"_").concat((i+"").toLowerCase());return r[n]||(r[n]={}),r[n]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){const{perfLimitSizeTotal:e}=o,s=Math.sqrt(e*t);return[Math.floor(s),Math.floor(e/s)]}};const x="6.5.1";function C(){}const b=Math.PI/2,w=2*Math.PI,S=Math.PI/180,T=Object.freeze([1,0,0,1,0,0]),O=16,k=.4477152502,D="center",M="left",P="top",E="bottom",A="right",j="none",F=/\r?\n/,L="moving",R="scaling",I="rotating",B="rotate",X="skewing",Y="resizing",W="modifyPoly",V="modifyPath",z="changed",H="scale",G="scaleX",N="scaleY",U="skewX",q="skewY",K="fill",J="stroke",Q="modified",Z="json",$="svg";const tt=new class{constructor(){this[Z]=new Map,this[$]=new Map}has(t){return this[Z].has(t)}getClass(t){const e=this[Z].get(t);if(!e)throw new h("No class registered for ".concat(t));return e}setClass(t,e){e?this[Z].set(e,t):(this[Z].set(t.type,t),this[Z].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[$].get(t)}setSVGClass(t,e){this[$].set(null!=e?e:t.type.toLowerCase(),t)}};const et=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 st{constructor(){t(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!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 t in this.__eventListeners)this._removeEventListener(t);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 t=0;t{const s=t.indexOf(e);return-1!==s&&t.splice(s,1),t},rt=t=>{if(0===t)return 1;switch(Math.abs(t)/b){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},nt=t=>{if(0===t)return 0;const e=t/b,s=Math.sign(t);switch(e){case 1:return s;case 2:return 0;case 3:return-s}return Math.sin(t)};class ot{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 ot(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new ot(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new ot(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new ot(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new ot(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new ot(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new ot(this.x/t.x,this.y/t.y)}scalarDivide(t){return new ot(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.xt.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 ot(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 ot(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new ot(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 ot(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at;const s=nt(t),i=rt(t),r=this.subtract(e);return new ot(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 ot(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 at=new ot(0,0),ht=t=>!!t&&Array.isArray(t._objects);function ct(e){class s extends e{constructor(){super(...arguments),t(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),s=0;sthis._onObjectAdded(t))),i}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis._onObjectAdded(t))),this._objects.length}remove(){const t=this._objects,e=[];for(var s=arguments.length,i=new Array(s),r=0;r{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;st.isType(...e)))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,e){return!!this._objects.includes(t)||!!e&&this._objects.some((e=>e instanceof s&&e.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])&&(it(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(it(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 it(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 it(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(it(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;s1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new ot(e,s),h=a.add(new ot(i,r));for(let t=this._objects.length-1;t>=0;t--){const e=this._objects[t];e.selectable&&e.visible&&(n&&e.intersectsWithRect(a,h)||e.isContainedWithinRect(a,h)||n&&e.containsPoint(a)||n&&e.containsPoint(h))&&o.push(e)}return o}}return s}class lt extends st{_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 ut(t){return v().requestAnimationFrame(t)}function dt(t){return v().cancelAnimationFrame(t)}let gt=0;const ft=()=>gt++,pt=()=>{const t=m().createElement("canvas");if(!t||void 0===t.getContext)throw new h("Failed to create `canvas` element");return t},mt=()=>m().createElement("img"),vt=t=>{const e=pt();return e.width=t.width,e.height=t.height,e},yt=(t,e,s)=>t.toDataURL("image/".concat(e),s),_t=t=>t*S,xt=t=>t/S,Ct=t=>t.every(((t,e)=>t===T[e])),bt=(t,e,s)=>new ot(t).transform(e,s),wt=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 ot(t[4],t[5]).transform(s,!0);return s[4]=-i,s[5]=-r,s},St=(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]],Tt=(t,e)=>t.reduceRight(((t,s)=>s&&t?St(s,t,e):s||t),void 0)||T.concat(),Ot=t=>{let[e,s]=t;return Math.atan2(s,e)},kt=t=>{const e=Ot(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:xt(e),scaleX:i,scaleY:r,skewX:xt(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},Dt=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Mt(){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=_t(t),r=rt(i),n=nt(i);return[r,n,-n,r,e?e-(r*e-n*s):0,s?s-(n*e+r*s):0]}const Pt=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Et=t=>Math.tan(_t(t)),At=t=>[1,0,Et(t),1,0,0],jt=t=>[1,Et(t),0,1,0,0],Ft=t=>{let{scaleX:e=1,scaleY:s=1,flipX:i=!1,flipY:r=!1,skewX:n=0,skewY:o=0}=t,a=Pt(i?-e:e,r?-s:s);return n&&(a=St(a,At(n),!0)),o&&(a=St(a,jt(o),!0)),a},Lt=t=>{const{translateX:e=0,translateY:s=0,angle:i=0}=t;let r=Dt(e,s);i&&(r=St(r,Mt({angle:i})));const n=Ft(t);return Ct(n)||(r=St(r,n)),r},Rt=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 c("loadImage"));const n=mt();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 h("Error loading ".concat(n.src)))},s&&(n.crossOrigin=s),n.src=t):a()}))},It=function(t){let{signal:e,reviver:s=C}=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=>tt.getClass(t.type).fromObject(t,{signal:e}).then((e=>(s(t,e),n.push(e),e)))))).then(i).catch((t=>{n.forEach((t=>{t.dispose&&t.dispose()})),r(t)})).finally((()=>{e&&e.removeEventListener("abort",r)}))}))},Bt=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&&tt.has(t.type)?It([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)}))}))},Xt=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce(((e,s)=>(s in t&&(e[s]=t[s]),e)),{})},Yt=(t,e)=>Object.keys(t).reduce(((s,i)=>(e(t[i],i,t)&&(s[i]=t[i]),s)),{}),Wt={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"},Vt=(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),zt=(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+(e0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},Gt=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),Nt=t=>{let[e,s,i,r=1]=t;const n=Math.round(.3*e+.59*s+.11*i);return[n,n,n,r]};class Ut{constructor(e){if(t(this,"isUnrecognised",!1),e)if(e instanceof Ut)this.setSource([...e._source]);else if(Array.isArray(e)){const[t,s,i,r=1]=e;this.setSource([t,s,i,r])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(t){return t in Wt&&(t=Wt[t]),"transparent"===t?[255,255,255,0]:Ut.sourceFromHex(t)||Ut.sourceFromRgb(t)||Ut.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=zt(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=zt(...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(Gt(t)).concat(Gt(e)).concat(Gt(s)).concat(Gt(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Nt(this.getSource())),this}toBlackWhite(t){const[e,,,s]=Nt(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof Ut||(t=new Ut(t));const e=this.getSource(),s=t.getSource(),[i,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 Ut.fromRgba(t)}static fromRgba(t){return new Ut(Ut.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[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,Ht(e[4])]}}static fromHsl(t){return Ut.fromHsla(t)}static fromHsla(t){return new Ut(Ut.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const s=(Ut.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,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=Vt(e,t,s+1/3),o=Vt(e,t,s),a=Vt(e,t,s-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*a),Ht(e[4])]}static fromHex(t){return new Ut(Ut.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map((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")?xt(s):e.includes("turn")?360*s:s}}const qt=(t,e)=>parseFloat(Number(t).toFixed(e)),Kt=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;const s=/\D{0,2}$/.exec(t),i=parseFloat(t),r=o.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}},Jt=t=>{const[e,s]=t.trim().split(" "),[i,r]=(n=e)&&n!==j?[n.slice(1,4),n.slice(5,8)]:n===j?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:s||"meet",alignX:i,alignY:r}},Qt=t=>"matrix("+t.map((t=>qt(t,o.NUM_FRACTION_DIGITS))).join(" ")+")",Zt=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 Ut(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,'" '):"")},$t=t=>!!t&&void 0!==t.toLive,te=t=>!!t&&"function"==typeof t.toObject,ee=t=>!!t&&void 0!==t.offsetX&&"source"in t,se=t=>!!t&&"function"==typeof t._renderText,ie=t=>!!t&&"multiSelectionStacking"in t;function re(t){const e=t&&ne(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 ne=t=>t.ownerDocument||null,oe=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},ae=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))},he=(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 ce(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=j,t}class le{constructor(e){t(this,"_originalCanvasStyle",void 0),t(this,"lower",void 0);const s=this.createLowerCanvas(e);this.lower={el:s,ctx:s.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&void 0!==s.getContext?t:t&&m().getElementById(t)||pt();var s;if(e.hasAttribute("data-fabric"))throw new h("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;ae(s,i,t,e)}setCSSDimensions(t){he(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&ne(t),i={left:0,top:0};if(!s)return i;const r=(null===(e=oe(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=re(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(){p().dispose(this.lower.el),delete this.lower}}const ue={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...T]};class de extends(ct(lt)){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 de.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}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new le(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;i0&&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&&(a("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?y():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:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e){const e=s({width:this.width,height:this.height},t);this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}i||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=bt(t,wt(i));i[0]=e,i[3]=e;const n=bt(r,i);i[4]+=s.x-n.x,i[5]+=s.y-n.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new ot(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 ot(-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=ut((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,s=wt(this.viewportTransform),i=bt({x:0,y:0},s),r=bt({x:t,y:e},s),n=i.min(r),o=i.max(r);return this.vptCoords={tl:n,tr:new ot(o.x,n.y),bl:new ot(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(dt(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const s=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const s=this.viewportTransform;t.save(),t.transform(...s),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let s=0,i=e.length;s!t.excludeFromExport)).map((s=>this._toObject(s,t,e)))},this.__serializeBgOverlay(t,e)),r?{clipPath:r}: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 $t(n)?n.excludeFromExport||(s.background=n.toObject(e)):n&&(s.background=n),$t(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('\n')),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push("\n"),this._setSVGBgOverlayColor(s,"overlay"),this._setSVGBgOverlayImage(s,"overlayImage",e),s.push(""),s.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('\n','\n')}_setSVGHeader(t,e){const s=e.width||"".concat(this.width),i=e.height||"".concat(this.height),r=o.NUM_FRACTION_DIGITS,n=e.viewBox;let a;if(n)a='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const t=this.viewportTransform;a='viewBox="'.concat(qt(-t[4]/t[0],r)," ").concat(qt(-t[5]/t[3],r)," ").concat(qt(this.width/t[0],r)," ").concat(qt(this.height/t[3],r),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("\n',"Created with Fabric.js ",x,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(ft()),'\n').concat(e.toClipPathSVG(t.reviver),"\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if($t(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?Qt(i):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},s=o.fontPaths;this._objects.forEach((function e(s){t.push(s),ht(s)&&s._objects.forEach(e)})),t.forEach((t=>{if(!se(t))return;const{styles:i,fontFamily:r}=t;!e[r]&&s[r]&&(e[r]=!0,i&&Object.values(i).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\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($t(s)){const i=s.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?Qt(wt(this.viewportTransform)):"";t.push('\n'))}else t.push('\n")}loadFromJSON(t,e){let{signal:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new h("`json` is undefined"));const i="string"==typeof t?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:o,overlayImage:a,overlay:c,clipPath:l}=i,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([It(r,{reviver:e,signal:s}),Bt({backgroundImage:n,backgroundColor:o,overlayImage:a,overlayColor:c,clipPath:l},{signal:s})]).then((t=>{let[e,s]=t;return this.clear(),this.add(...e),this.set(i),this.set(s),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=vt(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 yt(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=vt({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}),et.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"#")}}t(de,"ownDefaults",ue);const ge=["touchstart","touchmove","touchend"];const fe=t=>{const e=re(t.target),s=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new ot(s.clientX+e.left,s.clientY+e.top)},pe=t=>ge.includes(t.type)||"touch"===t.pointerType,me=t=>{t.preventDefault(),t.stopPropagation()},ve=t=>{let e=0,s=0,i=0,r=0;for(let n=0,o=t.length;ni||!n)&&(i=o),(or||!n)&&(r=a),(axe(t,St(e,t.calcOwnMatrix())),xe=(t,e)=>{const s=kt(e),{translateX:r,translateY:n,scaleX:o,scaleY:a}=s,h=i(s,ye),c=new ot(r,n);t.flipX=!1,t.flipY=!1,Object.assign(t,h),t.set({scaleX:o,scaleY:a}),t.setPositionByOrigin(c,D,D)},Ce=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},be=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}),we=(t,e,s)=>{const i=t/2,r=e/2,n=[new ot(-i,-r),new ot(i,-r),new ot(-i,r),new ot(i,r)].map((t=>t.transform(s))),o=ve(n);return new ot(o.width,o.height)},Se=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:T;return St(wt(arguments.length>1&&void 0!==arguments[1]?arguments[1]:T),t)},Te=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(Se(e,s))},Oe=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(Se(e,s),!0)},ke=(t,e,s)=>{const i=Se(e,s);return xe(t,St(i,t.calcOwnMatrix())),i},De=(t,e)=>{var i;const{transform:{target:r}}=e;null===(i=r.canvas)||void 0===i||i.fire("object:".concat(t),s(s({},e),{},{target:r})),r.fire(t,e)},Me={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Pe=t=>"string"==typeof t?Me[t]:t-.5,Ee="not-allowed";function Ae(t){return Pe(t.originX)===Pe(D)&&Pe(t.originY)===Pe(D)}function je(t){return.5-Pe(t)}const Fe=(t,e)=>t[e],Le=(t,e,s,i)=>({e:t,transform:e,pointer:new ot(s,i)});function Re(t,e){const s=t.getTotalAngle()+xt(Math.atan2(e.y,e.x))+360;return Math.round(s%360/45)}function Ie(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,D,D,s,i):new ot(t.left,t.top);return(t.angle?e.rotate(-_t(t.angle),r):e).subtract(n)}(o,new ot(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 Be=(t,e,s,i)=>{const{target:r,offsetX:n,offsetY:o}=e,a=s-n,h=i-o,c=!Fe(r,"lockMovementX")&&r.left!==a,l=!Fe(r,"lockMovementY")&&r.top!==h;return c&&r.set(M,a),l&&r.set(P,h),(c||l)&&De(L,Le(t,e,s,i)),c||l};class Xe{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",s=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):j,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=Zt(K,this.fill);return[Zt(J,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(Qt(s));return"".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(ft()),p='\n').concat(a.toClipPathSVG(s),"\n")),c&&g.push("\n"),g.push("\n");const m=[n,h,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,$t(u)&&g.push(u.toSVG(this)),$t(l)&&g.push(l.toSVG(this)),d&&g.push(d.toSVG(this)),a&&g.push(p),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==K?' paint-order="'.concat(this.paintFirst,'" '):""}}function Ye(t){return new RegExp("^("+t.join("|")+")\\b","i")}var We;const Ve=String.raw(We||(We=r(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),ze="http://www.w3.org/2000/svg",He=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Ve+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Ve+"))?\\s+(.*)"),Ge={cx:M,x:M,r:"radius",cy:P,y:P,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"},Ne="font-size",Ue="clip-path",qe=Ye(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),Ke=Ye(["symbol","image","marker","pattern","view","svg"]),Je=Ye(["symbol","g","a","svg","clipPath","defs"]),Qe=new RegExp("^\\s*("+Ve+"+)\\s*,?\\s*("+Ve+"+)\\s*,?\\s*("+Ve+"+)\\s*,?\\s*("+Ve+"+)\\s*$"),Ze=new ot(1,0),$e=new ot,ts=(t,e)=>t.rotate(e),es=(t,e)=>new ot(e).subtract(t),ss=t=>t.distanceFrom($e),is=(t,e)=>Math.atan2(as(t,e),hs(t,e)),rs=t=>is(Ze,t),ns=t=>t.eq($e)?t:t.scalarDivide(ss(t)),os=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ns(new ot(-t.y,t.x).scalarMultiply(e?1:-1))},as=(t,e)=>t.x*e.y-t.y*e.x,hs=(t,e)=>t.x*e.x+t.y*e.y,cs=(t,e,s)=>{if(t.eq(e)||t.eq(s))return!0;const i=as(e,s),r=as(e,t),n=as(s,t);return i>=0?r>=0&&n<=0:!(r<=0&&n>=0)},ls="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",us=new RegExp("(?:\\s|^)"+ls+ls+"("+Ve+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ds{constructor(t){const e="string"==typeof t?ds.parseShadow(t):t;Object.assign(this,ds.ownDefaults,e),this.id=ft()}static parseShadow(t){const e=t.trim(),[,s=0,i=0,r=0]=(us.exec(e)||[]).map((t=>parseFloat(t)||0));return{color:(e.replace(us,"")||"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=ts(new ot(this.offsetX,this.offsetY),_t(-t.angle)),s=new Ut(this.color);let i=40,r=40;return t.width&&t.height&&(i=100*qt((Math.abs(e.x)+this.blur)/t.width,o.NUM_FRACTION_DIGITS)+20,r=100*qt((Math.abs(e.y)+this.blur)/t.height,o.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\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=ds.ownDefaults;return this.includeDefaultValues?t:Yt(t,((t,s)=>t!==e[s]))}static async fromObject(t){return new this(t)}}t(ds,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),t(ds,"type","shadow"),tt.setClass(ds,"shadow");const gs=(t,e,s)=>Math.max(t,Math.min(e,s)),fs=[P,M,G,N,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",U,q],ps=[K,J,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ms={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:M,originY:P,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:K,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},vs=(t,e,s,i)=>(tt*Math.pow(2,10*(i-=1))*Math.sin((i*r-e)*w/s),_s=(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,xs=(t,e,s,i)=>(t/=i)<1/2.75?s*(7.5625*t*t)+e:t<2/2.75?s*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?s*(7.5625*(t-=2.25/2.75)*t+.9375)+e:s*(7.5625*(t-=2.625/2.75)*t+.984375)+e,Cs=(t,e,s,i)=>s-xs(i-t,0,s,i)+e;var bs=Object.freeze({__proto__:null,defaultEasing:_s,easeInBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*(t/=i)*t*((r+1)*t-r)+e},easeInBounce:Cs,easeInCirc:(t,e,s,i)=>-s*(Math.sqrt(1-(t/=i)*t)-1)+e,easeInCubic:(t,e,s,i)=>s*(t/i)**3+e,easeInElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h}=vs(r,s,n,1.70158);return-ys(o,a,h,t,i)+e},easeInExpo:(t,e,s,i)=>0===t?e:s*2**(10*(t/i-1))+e,easeInOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return(t/=i/2)<1?s/2*(t*t*((1+(r*=1.525))*t-r))+e:s/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInOutBounce:(t,e,s,i)=>t(t/=i/2)<1?-s/2*(Math.sqrt(1-t**2)-1)+e:s/2*(Math.sqrt(1-(t-=2)*t)+1)+e,easeInOutCubic:(t,e,s,i)=>(t/=i/2)<1?s/2*t**3+e:s/2*((t-2)**3+2)+e,easeInOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(2===(t/=i/2))return e+s;n||(n=i*(.3*1.5));const{a:o,s:a,p:h,c:c}=vs(r,s,n,1.70158);return t<1?-.5*ys(o,a,h,t,i)+e:o*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*w/h)*.5+c+e},easeInOutExpo:(t,e,s,i)=>0===t?e:t===i?e+s:(t/=i/2)<1?s/2*2**(10*(t-1))+e:s/2*-(2**(-10*--t)+2)+e,easeInOutQuad:(t,e,s,i)=>(t/=i/2)<1?s/2*t**2+e:-s/2*(--t*(t-2)-1)+e,easeInOutQuart:(t,e,s,i)=>(t/=i/2)<1?s/2*t**4+e:-s/2*((t-=2)*t**3-2)+e,easeInOutQuint:(t,e,s,i)=>(t/=i/2)<1?s/2*t**5+e:s/2*((t-2)**5+2)+e,easeInOutSine:(t,e,s,i)=>-s/2*(Math.cos(Math.PI*t/i)-1)+e,easeInQuad:(t,e,s,i)=>s*(t/=i)*t+e,easeInQuart:(t,e,s,i)=>s*(t/=i)*t**3+e,easeInQuint:(t,e,s,i)=>s*(t/i)**5+e,easeInSine:(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,easeOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*((t=t/i-1)*t*((r+1)*t+r)+1)+e},easeOutBounce:xs,easeOutCirc:(t,e,s,i)=>s*Math.sqrt(1-(t=t/i-1)*t)+e,easeOutCubic:(t,e,s,i)=>s*((t/i-1)**3+1)+e,easeOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h,c:c}=vs(r,s,n,1.70158);return o*2**(-10*t)*Math.sin((t*i-a)*w/h)+c+e},easeOutExpo:(t,e,s,i)=>t===i?e+s:s*-(2**(-10*t/i)+1)+e,easeOutQuad:(t,e,s,i)=>-s*(t/=i)*(t-2)+e,easeOutQuart:(t,e,s,i)=>-s*((t=t/i-1)*t**3-1)+e,easeOutQuint:(t,e,s,i)=>s*((t/i-1)**5+1)+e,easeOutSine:(t,e,s,i)=>s*Math.sin(t/i*b)+e});const ws=()=>!1;class Ss{constructor(e){let{startValue:s,byValue:i,duration:r=500,delay:n=0,easing:o=_s,onStart:a=C,onChange:h=C,onComplete:c=C,abort:l=ws,target:u}=e;t(this,"_state","pending"),t(this,"durationProgress",0),t(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=n,this.easing=o,this._onStart=a,this._onChange=h,this._onComplete=c,this._abort=l,this.target=u,this.startValue=s,this.byValue=i,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((()=>ut(t)),this.delay):ut(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),ut(this.tick)))}register(){et.push(this)}unregister(){et.remove(this)}abort(){this._state="aborted",this.unregister()}}const Ts=["startValue","endValue"];class Os extends Ss{constructor(t){let{startValue:e=0,endValue:r=100}=t;super(s(s({},i(t,Ts)),{},{startValue:e,byValue:r-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 ks=["startValue","endValue"];class Ds extends Ss{constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(s(s({},i(t,ks)),{},{startValue:e,byValue:r.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 Ms=["startValue","endValue","easing","onChange","onComplete","abort"],Ps=(t,e,s,i)=>e+s*(1-Math.cos(t/i*b)),Es=t=>t&&((e,s,i)=>t(new Ut(e).toRgba(),s,i));class As extends Ss{constructor(t){let{startValue:e,endValue:r,easing:n=Ps,onChange:o,onComplete:a,abort:h}=t,c=i(t,Ms);const l=new Ut(e).getSource(),u=new Ut(r).getSource();super(s(s({},c),{},{startValue:l,byValue:u.map(((t,e)=>t-l[e])),easing:n,onChange:Es(o),onComplete:Es(a),abort:Es(h)}))}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),gs(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 js(t){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(t)?new Ds(t):new Os(t);return e.start(),e}function Fs(t){const e=new As(t);return e.start(),e}class Ls{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!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=es(e,s),n=es(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 ot(t).setX(Math.min(t.x-1,...e.map((t=>t.x))));let i=0;for(let r=0;r4&&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 Ls("Intersection").append(new ot(t.x+e*o,t.y+e*a)):new Ls}if(0===d||0===g){const o=r||n||Ls.isPointContained(t,s,i)||Ls.isPointContained(e,s,i)||Ls.isPointContained(s,t,e)||Ls.isPointContained(i,t,e);return new Ls(o?"Coincident":void 0)}return new Ls("Parallel")}static intersectSegmentLine(t,e,s,i){return Ls.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return Ls.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 Ls,n=s.length;for(let o,a,h,c=0;c0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,s){return Ls.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new Ls,i=t.length,r=[];for(let n=0;n0&&r.length===t.length?new Ls("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 ot(r.x,i.y),o=new ot(i.x,r.y);return Ls.intersectPolygonPolygon(t,[i,n,r,o])}}class Rs extends lt{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?bt(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=bt(t,wt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new ot(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=>bt(e,t)))}return r}intersectsWithRect(t,e){return"Intersection"===Ls.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Ls.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}=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 Ls.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;if(this.intersectsWithRect(t,e))return!0;return 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 ve(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(G,t),this._set(N,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?xt(Ot(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||T.concat()}calcACoords(){const t=Mt({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=Dt(e,s),r=St(i,t),n=this._getTransformedDimensions(),o=n.x/2,a=n.y/2;return{tl:bt({x:-o,y:-a},r),tr:bt({x:o,y:-a},r),bl:bt({x:-o,y:a},r),br:bt({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,Pe(this.originX),Pe(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=St(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=Lt(i);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new ot(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=s({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let r=i,n=0;this.strokeUniform&&(r=0,n=i);const o=e.width+r,a=e.height+r;let h;return h=0===e.skewX&&0===e.skewY?new ot(o*e.scaleX,a*e.scaleY):we(o,a,Ft(e)),h.scalarAdd(n)}translateToGivenOrigin(t,e,s,i,r){let n=t.x,o=t.y;const a=Pe(i)-Pe(e),h=Pe(r)-Pe(s);if(a||h){const t=this._getTransformedDimensions();n+=a*t.x,o+=h*t.y}return new ot(n,o)}translateToCenterPoint(t,e,s){if(e===D&&s===D)return t;const i=this.translateToGivenOrigin(t,e,s,D,D);return this.angle?i.rotate(_t(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,D,D,e,s);return this.angle?i.rotate(_t(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?bt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new ot(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(),M,P)}}const Is=["type"],Bs=["extraParam"];let Xs=class e extends Rs{static getDefaults(){return e.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){a("warn","Setting type has no effect",t)}constructor(s){super(),t(this,"_cacheContext",null),Object.assign(this,e.ownDefaults),this.setOptions(s)}_createCacheCanvas(){this._cacheCanvas=pt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=o.maxCacheSideLimit,r=o.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=o.perfLimitSizeTotal)return ec&&(t.zoomX/=e/c,t.width=c,t.capped=!0),s>l&&(t.zoomY/=s/l,t.height=l,t.capped=!0),t}_getCacheCanvasDimensions(){const t=this.getTotalObjectScaling(),e=this._getTransformedDimensions({skewX:0,skewY:0}),s=e.x*t.x/this.scaleX,i=e.y*t.y/this.scaleY;return{width:s+2,height:i+2,zoomX:t.x,zoomY:t.y,x:s,y:i}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,s=this._limitCacheSize(this._getCacheCanvasDimensions()),i=o.minCacheSideLimit,r=s.width,n=s.height,a=s.zoomX,h=s.zoomY,c=r!==t.width||n!==t.height,l=this.zoomX!==a||this.zoomY!==h;if(!t||!e)return!1;let u,d,g=c||l,f=0,p=0,m=!1;if(c){const t=this._cacheCanvas.width,e=this._cacheCanvas.height,o=r>t||n>e;m=o||(r<.9*t||n<.9*e)&&t>i&&e>i,o&&!s.capped&&(r>i||n>i)&&(f=.1*r,p=.1*n)}return se(this)&&this.path&&(g=!0,m=!0,f+=this.getHeightOfLine(0)*this.zoomX,p+=this.getHeightOfLine(0)*this.zoomY),!!g&&(m?(t.width=Math.ceil(r+f),t.height=Math.ceil(n+p)):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height)),u=s.x/2,d=s.y/2,this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(a,h),this.zoomX=a,this.zoomY=h,!0)}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 ot(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=kt(this.calcTransformMatrix());return new ot(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){t.transform(i)})),e.parentClipPaths.push(t),t.absolutePositioned){const t=wt(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()),!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,$t(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&&($t(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)||T,a=r*i,h=n*i,c=e.nonScaling?new ot(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*o.browserShadowBlurConstant*(a+h)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*h*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!$t(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===J?(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=vt({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 ot(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(tt.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=be(this),s=this.group,i=this.shadow,r=Math.abs,n=t.enableRetinaScaling?y():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new de(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Ce(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&ke(this,this.getViewportTransform()),this.setCoords();const h=pt(),c=this.getBoundingRect(),l=this.shadow,u=new ot;if(l){const t=l.blur,e=l.nonScaling?new ot(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 ot(f.width/2,f.height/2),D,D);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 yt(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;s{let[i,r]=s;return t[i]=this._animate(i,r,e),t}),{})}_animate(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=t.split("."),n=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:h,onComplete:c}=i,l=s(s({},i),{},{target:this,startValue:null!=a?a:r.reduce(((t,e)=>t[e]),this),endValue:e,abort:null==o?void 0:o.bind(this),onChange:(t,e,s)=>{r.reduce(((e,s,i)=>(i===r.length-1&&(e[s]=t),e[s])),this),h&&h(t,e,s)},onComplete:(t,e,s)=>{this.setCoords(),c&&c(t,e,s)}});return n?Fs(l):js(l)}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-1&&n>o}toObject(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(e.customProperties,this.constructor.customProperties||[]);let i;const r=o.NUM_FRACTION_DIGITS,{clipPath:n,fill:a,stroke:h,shadow:c,strokeDashArray:l,left:u,top:d,originX:g,originY:f,width:p,height:m,strokeWidth:v,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:w,scaleX:S,scaleY:T,angle:O,flipX:k,flipY:D,opacity:M,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:L,skewY:R}=this;n&&!n.excludeFromExport&&(i=n.toObject(t.concat("inverted","absolutePositioned")));const I=t=>qt(t,r),B=s(s({},Xt(this,t)),{},{type:this.constructor.type,version:x,originX:g,originY:f,left:I(u),top:I(d),width:I(p),height:I(m),fill:te(a)?a.toObject():a,stroke:te(h)?h.toObject():h,strokeWidth:I(v),strokeDashArray:l?l.concat():l,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:I(w),scaleX:I(S),scaleY:I(T),angle:I(O),flipX:k,flipY:D,opacity:I(M),shadow:c?c.toObject():c,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:I(L),skewY:I(R)},i?{clipPath:i}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Yt(t,((t,e)=>{if(e===M||e===P||"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=i(t,Is),s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:r}=s,n=i(s,Bs);return Bt(e,n).then((t=>r?(delete t[r],new this(e[r],t)):new this(t)))}static fromObject(t,e){return this._fromObject(t,e)}};t(Xs,"stateProperties",fs),t(Xs,"cacheProperties",ps),t(Xs,"ownDefaults",ms),t(Xs,"type","FabricObject"),t(Xs,"colorProperties",[K,J,"backgroundColor"]),t(Xs,"customProperties",[]),tt.setClass(Xs),tt.setClass(Xs,"object");const Ys=(t,e,i)=>(r,n,o,a)=>{const h=e(r,n,o,a);return h&&De(t,s(s({},Le(r,n,o,a)),i)),h};function Ws(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 Vs=Ys(Y,Ws(((t,e,s,i)=>{const r=Ie(e,e.originX,e.originY,s,i);if(Pe(e.originX)===Pe(D)||Pe(e.originX)===Pe(A)&&r.x<0||Pe(e.originX)===Pe(M)&&r.x>0){const{target:t}=e,s=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=Ae(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 zs(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?J:K,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,w,!1),t[h](),c&&t.stroke(),t.restore()}function Hs(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?J:K,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(_t(d)),t["".concat(h,"Rect")](-l,-u,n,o),c&&t.strokeRect(-l,-u,n,o),t.restore()}class Gs{constructor(e){t(this,"visible",!0),t(this,"actionName",H),t(this,"angle",0),t(this,"x",0),t(this,"y",0),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"sizeX",0),t(this,"sizeY",0),t(this,"touchSizeX",0),t(this,"touchSizeY",0),t(this,"cursorStyle","crosshair"),t(this,"withConnection",!1),Object.assign(this,e)}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)&&Ls.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}positionHandler(t,e,s,i){return new ot(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,r,n){const o=Tt([Dt(s,i),Mt({angle:t}),Pt((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new ot(-.5,-.5).transform(o),tr:new ot(.5,-.5).transform(o),br:new ot(.5,.5).transform(o),bl:new ot(-.5,.5).transform(o)}}render(t,e,s,i,r){if("circle"===((i=i||{}).cornerStyle||r.cornerStyle))zs.call(this,t,e,s,i,r);else Hs.call(this,t,e,s,i,r)}}const Ns=(t,e,s)=>s.lockRotation?Ee:e.cursorStyle,Us=Ys(I,Ws(((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(Fe(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=xt(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){const i=qs(t,s);if(Ks(s,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return Ee;const r=Re(s,e);return"".concat(Js[r],"-resize")};function Zs(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const n=e.target,o=r.by,a=qs(t,n);let h,c,l,u,d,g;if(Ks(n,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,l=e.scaleY*e.gestureScale;else{if(h=Ie(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),Fe(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);Ae(e)&&(c*=2,l*=2),e.signX!==d&&"y"!==o&&(e.originX=je(e.originX),c*=-1,e.signX=d),e.signY!==g&&"x"!==o&&(e.originY=je(e.originY),l*=-1,e.signY=g)}const f=n.scaleX,p=n.scaleY;return o?("x"===o&&n.set(G,c),"y"===o&&n.set(N,l)):(!Fe(n,"lockScalingX")&&n.set(G,c),!Fe(n,"lockScalingY")&&n.set(N,l)),f!==n.scaleX||p!==n.scaleY}const $s=Ys(R,Ws(((t,e,s,i)=>Zs(t,e,s,i)))),ti=Ys(R,Ws(((t,e,s,i)=>Zs(t,e,s,i,{by:"x"})))),ei=Ys(R,Ws(((t,e,s,i)=>Zs(t,e,s,i,{by:"y"})))),si=["target","ex","ey","skewingSide"],ii={x:{counterAxis:"y",scale:G,skew:U,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:N,skew:q,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},ri=["ns","nesw","ew","nwse"],ni=(t,e,s)=>{if(0!==e.x&&Fe(s,"lockSkewingY"))return Ee;if(0!==e.y&&Fe(s,"lockSkewingX"))return Ee;const i=Re(s,e)%4;return"".concat(ri[i],"-resize")};function oi(t,e,r,n,o){const{target:a}=r,{counterAxis:h,origin:c,lockSkewing:l,skew:u,flip:d}=ii[t];if(Fe(a,l))return!1;const{origin:g,flip:f}=ii[h],p=Pe(r[g])*(a[f]?-1:1),m=-Math.sign(p)*(a[d]?-1:1),v=.5*-((0===a[u]&&Ie(r,D,D,n,o)[t]>0||a[u]>0?1:-1)*m)+.5,y=Ys(X,Ws(((e,s,r,n)=>function(t,e,s){let{target:r,ex:n,ey:o,skewingSide:a}=e,h=i(e,si);const{skew:c}=ii[t],l=s.subtract(new ot(n,o)).divide(new ot(r.scaleX,r.scaleY))[t],u=r[c],d=h[c],g=Math.tan(_t(d)),f="y"===t?r._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:r._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*l*a/Math.max(f,1)+g,m=xt(Math.atan(p));r.set(c,m);const v=u!==r[c];if(v&&"y"===t){const{skewX:t,scaleX:e}=r,s=r._getTransformedDimensions({skewY:u}),i=r._getTransformedDimensions(),n=0!==t?s.x/i.x:1;1!==n&&r.set(G,n*e)}return v}(t,s,new ot(r,n)))));return y(e,s(s({},r),{},{[c]:v,skewingSide:m}),n,o)}const ai=(t,e,s,i)=>oi("x",t,e,s,i),hi=(t,e,s,i)=>oi("y",t,e,s,i);function ci(t,e){return t[e.canvas.altActionKey]}const li=(t,e,s)=>{const i=ci(t,s);return 0===e.x?i?U:N:0===e.y?i?q:G:""},ui=(t,e,s)=>ci(t,s)?ni(0,e,s):Qs(t,e,s),di=(t,e,s,i)=>ci(t,e.target)?hi(t,e,s,i):ti(t,e,s,i),gi=(t,e,s,i)=>ci(t,e.target)?ai(t,e,s,i):ei(t,e,s,i),fi=()=>({ml:new Gs({x:-.5,y:0,cursorStyleHandler:ui,actionHandler:di,getActionName:li}),mr:new Gs({x:.5,y:0,cursorStyleHandler:ui,actionHandler:di,getActionName:li}),mb:new Gs({x:0,y:.5,cursorStyleHandler:ui,actionHandler:gi,getActionName:li}),mt:new Gs({x:0,y:-.5,cursorStyleHandler:ui,actionHandler:gi,getActionName:li}),tl:new Gs({x:-.5,y:-.5,cursorStyleHandler:Qs,actionHandler:$s}),tr:new Gs({x:.5,y:-.5,cursorStyleHandler:Qs,actionHandler:$s}),bl:new Gs({x:-.5,y:.5,cursorStyleHandler:Qs,actionHandler:$s}),br:new Gs({x:.5,y:.5,cursorStyleHandler:Qs,actionHandler:$s}),mtr:new Gs({x:0,y:-.5,actionHandler:Us,cursorStyleHandler:Ns,offsetY:-40,withConnection:!0,actionName:B})}),pi=()=>({mr:new Gs({x:.5,y:0,actionHandler:Vs,cursorStyleHandler:ui,actionName:Y}),ml:new Gs({x:-.5,y:0,actionHandler:Vs,cursorStyleHandler:ui,actionName:Y})}),mi=()=>s(s({},fi()),pi());class vi extends Xs{static getDefaults(){return s(s({},super.getDefaults()),vi.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),vi.ownDefaults),this.setOptions(t)}static createControls(){return{controls:fi()}}_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(H))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=Dt(e.x,e.y),i=Mt({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=St(s,i),n=St(t,r),o=St(n,[1/t[0],0,0,1/t[3],0,0]),a=this.group?kt(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)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(_t(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 i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=s({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:i,hasControls:r}=this,n=s({hasBorders:i,hasControls:r},e),o=this.getViewportTransform(),a=n.hasBorders,h=n.hasControls,c=St(o,this.calcTransformMatrix()),l=kt(c);t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(_t(this.group?l.angle:this.angle)),a&&this.drawBorders(t,l,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const t=we(this.width,this.height,Ft(e)),s=this.isStrokeAccountedForInDimensions()?at:(this.strokeUniform?(new ot).scalarAdd(this.canvas?this.canvas.getZoom():1):new ot(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 i=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:n,cornerColor:o}=this,a=s({cornerStrokeColor:r,cornerDashArray:n,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((e,s)=>{if(e.getVisibility(this,s)){const i=this.oCoords[s];e.render(t,i.x,i.y,a,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 yi(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}t(vi,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class _i extends vi{}yi(_i,[Xe]),tt.setClass(_i),tt.setClass(_i,"object");const xi=(t,e,s,i)=>{const r=2*(i=Math.round(i))+1,{data:n}=t.getImageData(e-i,s-i,r,r);for(let t=3;t0)return!1}return!0};class Ci{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new ot(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new ot(1/this.options.scaleX,1/this.options.scaleY):new ot(1,1)}createSideVector(t,e){const s=es(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 ot(t);return e.y+=e.x*Math.tan(_t(this.options.skewY)),e.x+=e.y*Math.tan(_t(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const bi=new ot;class wi extends Ci{static getOrthogonalRotationFactor(t,e){const s=e?is(t,e):rs(t);return Math.abs(s)2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),r=os(i),n=wi.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,s*n)}projectBevel(){const t=[];return(this.alpha%w==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?ss(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return ss(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new ot(wi.getOrthogonalRotationFactor(this.bisector),wi.getOrthogonalRotationFactor(new ot(this.bisector.y,this.bisector.x)));return[new ot(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new ot(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach((i=>{cs(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 ot(Math.tan(_t(i)),Math.tan(_t(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 ot(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 ot(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=>{cs(i,t,e)&&s.push(this.applySkew(this.A).add(i))})),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%w==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=as(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 Si extends Ci{constructor(t,e,s){super(s),this.A=new ot(t),this.T=new ot(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(os(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 ot(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 wi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new ot(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(ns(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 Ti=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 ot(e)),t)),[new ot(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],s,t))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 Si(t,t,e).project()):!s||0!==r&&r!==n.length-1?i.push(...new wi(t,o,a,e).project()):i.push(...new Si(t,0===r?a:o,e).project())})),i},Oi=t=>{const e={};return Object.keys(t).forEach((i=>{e[i]={},Object.keys(t[i]).forEach((r=>{e[i][r]=s({},t[i][r])}))})),e},ki=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">"),Di=t=>{const e=[];for(let s,i=0;i{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};var Pi=Object.freeze({__proto__:null,capitalize:function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"".concat(t.charAt(0).toUpperCase()).concat(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:ki,graphemeSplit:Di});const Ei=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.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||s&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},Ai=(t,e)=>{const s=e.split("\n"),i=[];let r=-1,n={};t=Oi(t);for(let e=0;e0&&(Ei(n,o,!0)?i.push({start:r,end:r+1,style:o}):i[i.length-1].end++),n=o||{}}else r+=o.length,n={}}return i},ji=(t,e)=>{if(!Array.isArray(t))return Oi(t);const i=e.split(F),r={};let n=-1,o=0;for(let e=0;e{var e;return null!==(e=Ge[t])&&void 0!==e?e:t},Bi=new RegExp("(".concat(Ve,")"),"gi"),Xi=t=>t.replace(Bi," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var Yi,Wi,Vi,zi,Hi,Gi,Ni;const Ui="(".concat(Ve,")"),qi=String.raw(Yi||(Yi=r(["(skewX)(",")"],["(skewX)\\(","\\)"])),Ui),Ki=String.raw(Wi||(Wi=r(["(skewY)(",")"],["(skewY)\\(","\\)"])),Ui),Ji=String.raw(Vi||(Vi=r(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Ui,Ui,Ui),Qi=String.raw(zi||(zi=r(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Ui,Ui),Zi=String.raw(Hi||(Hi=r(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Ui,Ui),$i=String.raw(Gi||(Gi=r(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Ui,Ui,Ui,Ui,Ui,Ui),tr="(?:".concat($i,"|").concat(Zi,"|").concat(Ji,"|").concat(Qi,"|").concat(qi,"|").concat(Ki,")"),er="(?:".concat(tr,"*)"),sr=String.raw(Ni||(Ni=r(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),er),ir=new RegExp(sr),rr=new RegExp(tr),nr=new RegExp(tr,"g");function or(t){const e=[];if(!(t=Xi(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!ir.test(t))return[...T];for(const s of t.matchAll(nr)){const t=rr.exec(s[0]);if(!t)continue;let i=T;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=Dt(a,h);break;case B:i=Mt({angle:a},{x:h,y:c});break;case H:i=Pt(a,h);break;case U:i=At(a);break;case q:i=jt(a);break;case"matrix":i=[a,h,c,l,u,d]}e.push(i)}return Tt(e)}function ar(t,e,s,i){const r=Array.isArray(e);let n,o=e;if(t!==K&&t!==J||e!==j){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===j?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=s&&s.transformMatrix?St(s.transformMatrix,or(e)):or(e);else if("visible"===t)o=e!==j&&"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?M:"end"===e?A:D;else if("charSpacing"===t)n=Kt(e,i)/i*1e3;else if("paintFirst"===t){const t=e.indexOf(K),s=e.indexOf(J);o=K,(t>-1&&s>-1&&s-1)&&(o=J)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=r?e.map(Kt):Kt(e,i)}}else o="";return!r&&isNaN(n)?o:n}function hr(t,e){const s=t.match(He);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=Kt(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}function cr(t,e){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[s,i]=t.split(":");e[s.trim().toLowerCase()]=i.trim()}))}function lr(t){const e={},s=t.getAttribute("style");return s?("string"==typeof s?cr(s,e):function(t,e){Object.entries(t).forEach((t=>{let[s,i]=t;void 0!==i&&(e[s.toLowerCase()]=i)}))}(s,e),e):e}const ur={stroke:"strokeOpacity",fill:"fillOpacity"};function dr(t,e,i){if(!t)return{};let r,n={},o=O;t.parentNode&&Je.test(t.parentNode.nodeName)&&(n=dr(t.parentElement,e,i),n.fontSize&&(r=o=Kt(n.fontSize)));const a=s(s(s({},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]:{},i={};for(const r in e)Ri(t,r.split(" "))&&(i=s(s({},i),e[r]));return i}(t,i)),lr(t));a[Ue]&&t.setAttribute(Ue,a[Ue]),a[Ne]&&(r=Kt(a[Ne],o),a[Ne]="".concat(r));const h={};for(const t in a){const e=Ii(t),s=ar(e,a[t],n,r);h[e]=s}h&&h.font&&hr(h.font,h);const c=s(s({},n),h);return Je.test(t.nodeName)?c:function(t){const e=_i.getDefaults();return Object.entries(ur).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 Ut(t[i]);t[i]=n.setAlpha(qt(n.getAlpha()*t[r],2)).toRgba()})),t}(c)}const gr=["left","top","width","height","visible"],fr=["rx","ry"];class pr extends _i{static getDefaults(){return s(s({},super.getDefaults()),pr.ownDefaults)}constructor(t){super(),Object.assign(this,pr.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-k*n,r,i+e,r+k*o,i+e,r+o),t.lineTo(i+e,r+s-o),a&&t.bezierCurveTo(i+e,r+s-k*o,i+e-k*n,r+s,i+e-n,r+s),t.lineTo(i+n,r+s),a&&t.bezierCurveTo(i+k*n,r+s,i,r+s-k*o,i,r+s-o),t.lineTo(i,r+o),a&&t.bezierCurveTo(i,r+k*o,i+k*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([...fr,...t])}_toSVG(){const{width:t,height:e,rx:s,ry:i}=this;return["\n')]}static async fromElement(t,e,r){const n=dr(t,this.ATTRIBUTE_NAMES,r),{left:o=0,top:a=0,width:h=0,height:c=0,visible:l=!0}=n,u=i(n,gr);return new this(s(s(s({},e),u),{},{left:o,top:a,width:h,height:c,visible:Boolean(l&&h&&c)}))}}t(pr,"type","Rect"),t(pr,"cacheProperties",[...ps,...fr]),t(pr,"ownDefaults",{rx:0,ry:0}),t(pr,"ATTRIBUTE_NAMES",[...Fi,"x","y","rx","ry","width","height"]),tt.setClass(pr),tt.setSVGClass(pr);const mr="initialization",vr="added",yr="removed",_r="imperative",xr=(t,e)=>{const{strokeUniform:s,strokeWidth:i,width:r,height:n,group:o}=e,a=o&&o!==t?Se(o.calcTransformMatrix(),t.calcTransformMatrix()):null,h=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),l=s&&c?Oe(new ot(i,i),void 0,t.calcTransformMatrix()):at,u=!s&&c?i:0,d=we(r+u,n+u,Tt([a,e.calcOwnMatrix()],!0)).add(l).scalarDivide(2);return[h.subtract(d),h.add(d)]};class Cr{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===mr||e===_r||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==mr&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===_r&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:n,width:o,height:a}=ve(t.map((t=>xr(i,t))).reduce(((t,e)=>t.concat(e)),[])),h=new ot(o,a),c=new ot(r,n).add(h.scalarDivide(2));if(s===mr){const t=this.getInitialSize(e,{size:h,center:c});return{center:c,relativeCorrection:new ot(0,0),size:t}}return{center:c.transform(i.calcOwnMatrix()),size:h}}}t(Cr,"type","strategy");class br extends Cr{shouldPerformLayout(t){return!0}}t(br,"type","fit-content"),tt.setClass(br);const wr=["strategy"],Sr=["target","strategy","bubbles","prevStrategy"],Tr="layoutManager";class Or{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new br;t(this,"strategy",void 0),this.strategy=e,this._subscriptions=new Map}performLayout(t){const e=s(s({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:s}=e;return[Q,L,Y,I,R,X,z,W,V].map((e=>t.on(e,(t=>this.performLayout(e===Q?{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:r}=t,{canvas:n}=e;if(r===mr||r===vr?this.subscribeTargets(t):r===yr&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),n&&n.fire("object:layout:before",{target:e,context:t}),r===_r&&t.deep){const r=i(t,wr);e.forEachObject((t=>t.layoutManager&&t.layoutManager.performLayout(s(s({},r),{},{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===mr?new ot:e.getRelativeCenterPoint(),{center:o,correction:a=new ot,relativeCorrection:h=new ot}=r,c=n.subtract(o).add(a).transform(i===mr?T:wt(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===mr)?s.set({left:null!==(n=t.x)&&void 0!==n?n:r.x+i.x*Pe(s.originX),top:null!==(o=t.y)&&void 0!==o?o:r.y+i.y*Pe(s.originY)}):(s.setPositionByOrigin(r,D,D),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:r,strategy:n,bubbles:o,prevStrategy:a}=t,h=i(t,Sr),{canvas:c}=r;r.fire("layout:after",{context:t,result:e}),c&&c.fire("object:layout:after",{context:t,result:e,target:r});const l=r.parent;o&&null!=l&&l.layoutManager&&((h.path||(h.path=[])).push(r),l.layoutManager.performLayout(s(s({},h),{},{target:l}))),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((t=>t.forEach((t=>t())))),t.clear()}toObject(){return{type:Tr,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}tt.setClass(Or,Tr);const kr=["type","objects","layoutManager"];class Dr extends Or{performLayout(){}}class Mr extends(ct(_i)){static getDefaults(){return s(s({},super.getDefaults()),Mr.ownDefaults)}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"_activeObjects",[]),t(this,"__objectSelectionTracker",void 0),t(this,"__objectSelectionDisposer",void 0),Object.assign(this,Mr.ownDefaults),this.setOptions(s),this.groupInit(e,s)}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 Or,this.layoutManager.performLayout({type:mr,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(a("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(a("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;s1?e-1:0),i=1;i{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&&xe(t,St(wt(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||(xe(t,St(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=_i.prototype.shouldCache.call(this);if(t)for(let t=0;tt.setCoords()))}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(s({target:this,type:_r},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 s(s(s({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#")}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=pr.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=["\n"],s=this._createSVGBgRect(t);s&&e.push("\t\t",s);for(let s=0;s\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 s=0;s{let[e,i]=t;const r=new this(e,s(s(s({},a),i),{},{layoutManager:new Dr}));if(o){const t=tt.getClass(o.type),e=tt.getClass(o.strategy);r.layoutManager=new t(new e)}else r.layoutManager=new Or;return r.layoutManager.subscribeTargets({type:mr,target:r,targets:r.getObjects()}),r.setCoords(),r}))}}t(Mr,"type","Group"),t(Mr,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tt.setClass(Mr);const Pr=(t,e)=>Math.min(e.width/t.width,e.height/t.height),Er=(t,e)=>Math.max(e.width/t.width,e.height/t.height),Ar="\\s*,?\\s*",jr="".concat(Ar,"(").concat(Ve,")"),Fr="".concat(jr).concat(jr).concat(jr).concat(Ar,"([01])").concat(Ar,"([01])").concat(jr).concat(jr),Lr={m:"l",M:"L"},Rr=(t,e,s,i,r,n,o,a,h,c,l)=>{const u=rt(t),d=nt(t),g=rt(e),f=nt(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]},Ir=(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 Br(t,e,s,i,r,n,a,h){let c;if(o.cachesBoundsOfCurve&&(c=[...arguments].join(),_.boundsOfCurveCache[c]))return _.boundsOfCurveCache[c];const l=Math.sqrt,u=Math.abs,d=[],g=[[0,0],[0,0]];let f=6*t-12*s+6*r,p=-3*t+9*s-9*r+3*a,m=3*s-3*t;for(let t=0;t<2;++t){if(t>0&&(f=6*e-12*i+6*n,p=-3*e+9*i-9*n+3*h,m=3*i-3*e),u(p)<1e-12){if(u(f)<1e-12)continue;const t=-m/f;0{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*S,d=nt(u),g=rt(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,T=-c*b*f/C,O=g*w-d*T+.5*t,k=d*w+g*T+.5*e;let D=Ir(1,0,(f-w)/C,(p-T)/b),M=Ir((f-w)/C,(p-T)/b,(-f-w)/C,(-p-T)/b);0===n&&M>0?M-=2*l:1===n&&M<0&&(M+=2*l);const P=Math.ceil(Math.abs(M/l*2)),E=[],A=M/P,j=8/3*Math.sin(A/4)*Math.sin(A/4)/Math.sin(A/2);let F=D+A;for(let t=0;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;case"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":Xr(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},Wr=(t,e,s,i)=>Math.sqrt((s-t)**2+(i-e)**2),Vr=(t,e,s,i,r,n,o,a)=>h=>{const c=h**3,l=(t=>3*t**2*(1-t))(h),u=(t=>3*t*(1-t)**2)(h),d=(t=>(1-t)**3)(h);return new ot(o*c+r*l+s*u+t*d,a*c+n*l+i*u+e*d)},zr=t=>t**2,Hr=t=>2*t*(1-t),Gr=t=>(1-t)**2,Nr=(t,e,s,i,r,n,o,a)=>h=>{const c=zr(h),l=Hr(h),u=Gr(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)},Ur=(t,e,s,i,r,n)=>o=>{const a=zr(o),h=Hr(o),c=Gr(o);return new ot(r*a+s*h+t*c,n*a+i*h+e*c)},qr=(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)},Kr=(t,e,s)=>{let i=new ot(e,s),r=0;for(let e=1;e<=100;e+=1){const s=t(e/100);r+=Wr(i.x,i.y,s.x,s.y),i=s}return r},Jr=(t,e)=>{let i,r=0,n=0,o={x:t.x,y:t.y},a=s({},o),h=.01,c=0;const l=t.iterator,u=t.angleFinder;for(;n1e-4;)a=l(r),c=r,i=Wr(o.x,o.y,a.x,a.y),i+n>e?(r-=h,h/=2):(o=a,r+=h,n+=i);return s(s({},a),{},{angle:u(c)})},Qr=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=Wr(r,n,c[1],c[2]),r=c[1],n=c[2];break;case"C":e=Vr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s=t,s.iterator=e,s.angleFinder=Nr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s.length=Kr(e,r,n),r=c[5],n=c[6];break;case"Q":e=Ur(r,n,c[1],c[2],c[3],c[4]),s=t,s.iterator=e,s.angleFinder=qr(r,n,c[1],c[2],c[3],c[4]),s.length=Kr(e,r,n),r=c[3],n=c[4];break;case"Z":s=t,s.destX=o,s.destY=a,s.length=Wr(r,n,o,a),r=o,n=a}i+=s.length,h.push(s)}return h.push({length:i,x:r,y:n}),h},Zr=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Qr(t),r=0;for(;e-i[r].length>0&&r{var e;const s=[],i=null!==(e=t.match($r))&&void 0!==e?e:[];for(const t of i){const e=t[0];if("z"===e||"Z"===e){s.push([e]);continue}const i=sn[e.toLowerCase()];let r=[];if("a"===e||"A"===e){tn.lastIndex=0;for(let e=null;e=tn.exec(t);)r.push(...e.slice(1))}else r=t.match(en)||[];for(let t=0;t0&&o?o:e;for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:0,s=new ot(t[0]),i=new ot(t[1]),r=1,n=0;const o=[],a=t.length,h=a>2;let c;for(h&&(r=t[2].xt[c-2].x?1:s.x===t[c-2].x?0:-1,n=s.y>t[c-2].y?1:s.y===t[c-2].y?0:-1),o.push(["L",s.x+r*e,s.y+n*e]),o},on=(t,e)=>t.map((t=>t.map(((t,s)=>0===s||void 0===e?t:qt(t,e))).join(" "))).join(" ");function an(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)})))}const hn=(t,e)=>Math.floor(Math.random()*(e-t+1))+t;function cn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e.onComplete||C,i=new(v().XMLHttpRequest),r=e.signal,n=function(){i.abort()},o=function(){r&&r.removeEventListener("abort",n),i.onerror=i.ontimeout=C};if(r&&r.aborted)throw new c("request");return r&&r.addEventListener("abort",n,{once:!0}),i.onreadystatechange=function(){4===i.readyState&&(o(),s(i),i.onreadystatechange=C)},i.onerror=i.ontimeout=o,i.open("get",t,!0),i.send(),i}const ln=(t,e)=>{let s=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){const{scaleX:e,scaleY:s,angle:i,skewX:r}=kt(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(G,e),t.set(N,s),t.angle=i,t.skewX=r,t.skewY=0}})(t),s=s.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,s.x+=e.offsetLeft,s.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(s,D,D)};var un=Object.freeze({__proto__:null,addTransformToObject:_e,animate:js,animateColor:Fs,applyTransformToObject:xe,calcAngleBetweenVectors:is,calcDimensionsMatrix:Ft,calcPlaneChangeMatrix:Se,calcVectorRotation:rs,cancelAnimFrame:dt,capValue:gs,composeMatrix:Lt,copyCanvasElement:t=>{var e;const s=vt(t);return null===(e=s.getContext("2d"))||void 0===e||e.drawImage(t,0,0),s},cos:rt,createCanvasElement:pt,createImage:mt,createRotateMatrix:Mt,createScaleMatrix:Pt,createSkewXMatrix:At,createSkewYMatrix:jt,createTranslateMatrix:Dt,createVector:es,crossProduct:as,degreesToRadians:_t,dotProduct:hs,ease:bs,enlivenObjectEnlivables:Bt,enlivenObjects:It,findScaleToCover:Er,findScaleToFit:Pr,getBoundsOfCurve:Br,getOrthonormalVector:os,getPathSegmentsInfo:Qr,getPointOnPath:Zr,getPointer:fe,getRandomInt:hn,getRegularPolygonPath:(t,e)=>{const s=2*Math.PI/t;let i=-b;t%2==0&&(i+=s/2);const r=new Array(t+1);for(let n=0;n{const e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},getUnitVector:ns,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new Mr(t,e),hasStyleChanged:Ei,invertTransform:wt,isBetweenVectors:cs,isIdentityMatrix:Ct,isTouchEvent:pe,isTransparent:xi,joinPath:on,loadImage:Rt,magnitude:ss,makeBoundingBoxFromPoints:ve,makePathSimpler:Yr,matrixToSVG:Qt,mergeClipPaths:(t,e)=>{var s;let i=t,r=e;i.inverted&&!r.inverted&&(i=e,r=t),ke(r,null===(s=r.group)||void 0===s?void 0:s.calcTransformMatrix(),i.calcTransformMatrix());const n=i.inverted&&r.inverted;return n&&(i.inverted=r.inverted=!1),new Mr([i],{clipPath:r,inverted:n})},multiplyTransformMatrices:St,multiplyTransformMatrixArray:Tt,parsePath:rn,parsePreserveAspectRatioAttribute:Jt,parseUnit:Kt,pick:Xt,projectStrokeOnPoints:Ti,qrDecompose:kt,radiansToDegrees:xt,removeFromArray:it,removeTransformFromObject:(t,e)=>{const s=wt(e),i=St(s,t.calcOwnMatrix());xe(t,i)},removeTransformMatrixForSvgParsing:ln,request:cn,requestAnimFrame:ut,resetObjectTransform:Ce,rotatePoint:(t,e,s)=>t.rotate(s,e),rotateVector:ts,saveObjectTransform:be,sendObjectToPlane:ke,sendPointToPlane:Te,sendVectorToPlane:Oe,setStyle:an,sin:nt,sizeAfterTransform:we,string:Pi,stylesFromArray:ji,stylesToArray:Ai,toDataURL:yt,toFixed:qt,transformPath:(t,e,s)=>(s&&(e=St(e,[1,0,0,1,-s.x,-s.y])),t.map((t=>{const s=[...t];for(let i=1;i1&&void 0!==arguments[1]?arguments[1]:{};super(e),t(this,"upper",void 0),t(this,"container",void 0);const{el:r}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:s}),this.applyCanvasStyle(n,{allowTouchScrolling:s,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=pt();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=m().createElement("div");return t.setAttribute("data-fabric","wrapper"),an(t,{position:"relative"}),ce(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:r}=e;an(t,s(s({},i),{},{"touch-action":r?"manipulation":j})),ce(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:s,ctx:i}=this.upper;ae(s,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),he(this.upper.el,t),he(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(),p().dispose(this.upper.el),delete this.upper,delete this.container}}class gn extends de{constructor(){super(...arguments),t(this,"targets",[]),t(this,"_hoveredTargets",[]),t(this,"_objectsToRender",void 0),t(this,"_currentTransform",null),t(this,"_groupSelector",null),t(this,"contextTopDirty",!1)}static getDefaults(){return s(s({},super.getDefaults()),gn.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 dn(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)}isTargetTransparent(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 xi(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===H||e===G||e===N||e===Y?i=this.centeredScaling||t.centeredScaling:e===B&&(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=A:["mr","tr","br"].includes(e)&&(s.x=M),["tl","mt","tr"].includes(e)?s.y=E:["bl","mb","br"].includes(e)&&(s.y=P),s):s}_setupCurrentTransform(t,e,i){var r;const n=e.group?Te(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},h=i&&a?null===(r=a.getActionHandler(t,e,a))||void 0===r?void 0:r.bind(a):Be,c=((t,e,s,i)=>{if(!e||!t)return"drag";const r=i.controls[e];return r.getActionName(s,r,i)})(i,o,t,e),l=t[this.centeredKey],u=this._shouldCenterTransform(e,c,l)?{x:D,y:D}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:h,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:_t(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:l,original:s(s({},be(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new ot(e,s).transform(this.viewportTransform),o=new ot(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,_i.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,pe(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=rt(o)*r,h=nt(o)*r,c=a+h,l=a-h;s=[new ot(t.x-l,t.y-c),new ot(e.x+c,e.y-l),new ot(i.x+l,i.y+c),new ot(n.x-c,n.y+l)]}return Ls.isPointInPolygon(e,s)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Te(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;if(!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(ht(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&&ht(s)&&s.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const s=t[e];if(!ht(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=fe(t),n=i.width||0,o=i.height||0;n&&o||(P in i&&E in i&&(o=Math.abs(i.top-i.bottom)),A in i&&M 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=Te(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const h=0===n||0===o?new ot(1,1):new ot(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=pt(),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 ie(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,ie(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),ie(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(Q,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ie(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&&ie(e)&&this._activeObject===e){const s=Xt(t,["angle","flipX","flipY",M,G,N,U,q,P]);return _e(t,e.calcOwnMatrix()),s}return{}}_setSVGObject(t,e,s){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,s),e.set(i)}}t(gn,"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,hoverCursor:"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 fn{constructor(e){t(this,"targets",[]),t(this,"__disposer",void 0);const s=()=>{const{hiddenTextarea:t}=e.getActiveObject()||{};t&&t.focus()},i=e.upperCanvasEl;i.addEventListener("click",s),this.__disposer=()=>i.removeEventListener("click",s)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),it(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 pn=["target","oldTarget","fireCanvas","e"],mn={passive:!1},vn=(t,e)=>{const s=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:s,scenePoint:i,pointer:s,absolutePointer:i}},yn=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{}),t(this,"_isClick",void 0),t(this,"textEditingManager",new fn(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((t=>{this[t]=this[t].bind(this)})),this.addOrRemove(yn,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const s=this.upperCanvasEl,i=this._getEventPrefix();t(oe(s),"resize",this._onResize),t(s,i+"down",this._onMouseDown),t(s,"".concat(i,"move"),this._onMouseMove,mn),t(s,"".concat(i,"out"),this._onMouseOut),t(s,"".concat(i,"enter"),this._onMouseEnter),t(s,"wheel",this._onMouseWheel),t(s,"contextmenu",this._onContextMenu),t(s,"dblclick",this._onDoubleClick),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,mn)}removeListeners(){this.addOrRemove(_n,"remove");const t=this._getEventPrefix(),e=ne(this.upperCanvasEl);_n(e,"".concat(t,"up"),this._onMouseUp),_n(e,"touchend",this._onTouchEnd,mn),_n(e,"".concat(t,"move"),this._onMouseMove,mn),_n(e,"touchmove",this._onMouseMove,mn),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=s({e:t},vn(this,t));this.fire("mouse:out",s(s({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",s({},i)),this._hoveredTargets.forEach((t=>{this.fire("mouse:out",s(s({},i),{},{target:t})),t&&t.fire("mouseout",s({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",s({e:t},vn(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 yn(this.upperCanvasEl,"drag",this._onDragProgress)}me(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(),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!==j,s=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:s};_n(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){this.targets=[];return{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 s=0;s0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),s=ne(this.upperCanvasEl);_n(s,"touchend",this._onTouchEnd,mn),_n(s,"touchmove",this._onMouseMove,mn),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{yn(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=ne(this.upperCanvasEl);_n(t,"".concat(s,"up"),this._onMouseUp),_n(t,"".concat(s,"move"),this._onMouseMove,mn),yn(e,"".concat(s,"move"),this._onMouseMove,mn)}}_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");const 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),pe(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{s=t.hoverCursor||s})),this.setCursor(s)}handleMultiSelection(t,e){const s=this._activeObject,i=ie(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(tt.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 ot(e,s),o=n.add(new ot(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=tt.getClass("ActiveSelection");this.setActiveObject(new e(l,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const bn={x1:0,y1:0,x2:0,y2:0},wn=s(s({},bn),{},{r1:0,r2:0}),Sn=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,Tn=/^(\d+\.\d+)%|(\d+)%$/;function On(t){return t&&Tn.test(t)}function kn(t,e){const s="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(On(t)?100:1):NaN;return gs(0,Sn(s,e),1)}const Dn=/\s*;\s*/,Mn=/\s*:\s*/;function Pn(t,e){let s,i;const r=t.getAttribute("style");if(r){const t=r.split(Dn);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,n]=t[e].split(Mn).map((t=>t.trim()));"stop-color"===r?s=n:"stop-opacity"===r&&(i=n)}}const n=new Ut(s||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:kn(t.getAttribute("offset"),0),color:n.toRgb(),opacity:Sn(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*n.getAlpha()*e}}function En(t,e){const s=[],i=t.getElementsByTagName("stop"),r=kn(e,1);for(let t=i.length;t--;)s.push(Pn(i[t],r));return s}function An(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function jn(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function Fn(t,e){return t.getAttribute(e)}function Ln(t,e){return function(t,e){let s,{width:i,height:r,gradientUnits:n}=e;return Object.keys(t).reduce(((e,o)=>{const a=t[o];return"Infinity"===a?s=1:"-Infinity"===a?s=0:(s="string"==typeof a?parseFloat(a):a,"string"==typeof a&&On(a)&&(s*=.01,"pixels"===n&&("x1"!==o&&"x2"!==o&&"r2"!==o||(s*=i),"y1"!==o&&"y2"!==o||(s*=r)))),e[o]=s,e}),{})}("linear"===An(t)?function(t){return{x1:Fn(t,"x1")||0,y1:Fn(t,"y1")||0,x2:Fn(t,"x2")||"100%",y2:Fn(t,"y2")||0}}(t):function(t){return{x1:Fn(t,"fx")||Fn(t,"cx")||"50%",y1:Fn(t,"fy")||Fn(t,"cy")||"50%",r1:0,x2:Fn(t,"cx")||"50%",y2:Fn(t,"cy")||"50%",r2:Fn(t,"r")||"50%"}}(t),s(s({},e),{},{gradientUnits:jn(t)}))}class Rn{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:r={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:h,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:s(s({},"radial"===e?wn:bn),r),colorStops:n,offsetX:o,offsetY:a,gradientTransform:h,id:c?"".concat(c,"_").concat(ft()):ft()})}addColorStop(t){for(const e in t){const s=new Ut(t[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this}toObject(t){return s(s({},Xt(this,t)),{},{type:this.type,coords:s({},this.coords),colorStops:this.colorStops.map((t=>s({},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 i=[],r=this.gradientTransform?this.gradientTransform.concat():T.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((t=>s({},t))).sort(((t,e)=>t.offset-e.offset));let a=-this.offsetX,h=-this.offsetY;var c;"objectBoundingBox"===n?(a/=t.width,h/=t.height):(a+=t.width/2,h+=t.height/2),(c=t)&&"function"==typeof c._renderPathCommands&&"percentage"!==this.gradientUnits&&(a-=t.pathOffset.x,h-=t.pathOffset.y),r[4]-=a,r[5]-=h;const l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Qt(r),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:s,y2:r}=this.coords;i.push("\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:s,y2:r,r1:n,r2:a}=this.coords,h=n>a;i.push("\n'),h&&(o.reverse(),o.forEach((t=>{t.offset=1-t.offset})));const c=Math.min(n,a);if(c>0){const t=c/Math.max(n,a);o.forEach((e=>{e.offset+=t*(1-e.offset)}))}}return o.forEach((t=>{let{color:e,offset:s,opacity:r}=t;i.push("\n')})),i.push("linear"===this.type?"":"","\n"),i.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 Ut(e).setAlpha(s).toRgba():e)})),a}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(s(s({},t),{},{colorStops:e?e.map((t=>s({},t))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const r=jn(t),n=e._findCenterFromElement();return new this(s({id:t.getAttribute("id")||void 0,type:An(t),coords:Ln(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:En(t,i.opacity),gradientUnits:r,gradientTransform:or(t.getAttribute("gradientTransform")||"")},"pixels"===r?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}t(Rn,"type","Gradient"),tt.setClass(Rn,"gradient"),tt.setClass(Rn,"linear"),tt.setClass(Rn,"radial");const In=["type","source","patternTransform"];class Bn{get type(){return"pattern"}set type(t){a("warn","Setting type has no effect",t)}constructor(e){t(this,"repeat","repeat"),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"crossOrigin",""),this.id=ft(),Object.assign(this,e)}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:i}=this;return s(s({},Xt(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:qt(this.offsetX,o.NUM_FRACTION_DIGITS),offsetY:qt(this.offsetY,o.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=Sn(this.offsetX/e,0),a=Sn(this.offsetY/s,0),h="repeat-y"===r||"no-repeat"===r?1+Math.abs(o||0):Sn(i.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):Sn(i.height/s,0);return[''),''),"",""].join("\n")}static async fromObject(t,e){let{type:r,source:n,patternTransform:o}=t,a=i(t,In);const h=await Rt(n,s(s({},e),{},{crossOrigin:a.crossOrigin}));return new this(s(s({},a),{},{patternTransform:o&&o.slice(0),source:h}))}}t(Bn,"type","Pattern"),tt.setClass(Bn),tt.setClass(Bn,"pattern");class Xn{constructor(e){t(this,"color","rgb(0, 0, 0)"),t(this,"width",1),t(this,"shadow",null),t(this,"strokeLineCap","round"),t(this,"strokeLineJoin","round"),t(this,"strokeMiterLimit",10),t(this,"strokeDashArray",null),t(this,"limitedToCanvasSize",!1),this.canvas=e}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new Ut(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,s=t.contextTop,i=t.getZoom()*t.getRetinaScaling();s.shadowColor=e.color,s.shadowBlur=e.blur*i,s.shadowOffsetX=e.offsetX*i,s.shadowOffsetY=e.offsetY*i}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}const Yn=["path","left","top"],Wn=["d"];class Vn extends _i{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:s,left:r,top:n}=e,o=i(e,Yn);super(),Object.assign(this,Vn.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),"number"==typeof r&&this.set(M,r),"number"==typeof n&&this.set(P,n)}_setPath(t,e){this.path=Yr(Array.isArray(t)?t:rn(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new ot(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"#")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(s({},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=on(this.path,o.NUM_FRACTION_DIGITS);return["\n')]}_getOffsetTransform(){const t=o.NUM_FRACTION_DIGITS;return" translate(".concat(qt(-this.pathOffset.x,t),", ").concat(qt(-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,D,D)}_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(...Br(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(...Br(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 ve(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return s(s({},t),{},{pathOffset:new ot(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const n=dr(t,this.ATTRIBUTE_NAMES,r),{d:o}=n;return new this(o,s(s(s({},i(n,Wn)),e),{},{left:void 0,top:void 0}))}}t(Vn,"type","Path"),t(Vn,"cacheProperties",[...ps,"path","fillRule"]),t(Vn,"ATTRIBUTE_NAMES",[...Fi,"d"]),tt.setClass(Vn),tt.setSVGClass(Vn);class zn extends Xn{constructor(e){super(e),t(this,"decimate",.4),t(this,"drawStraightLine",!1),t(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,s){const i=e.midPointFrom(s);return t.quadraticCurveTo(e.x,e.y,i.x,i.y),i}onMouseDown(t,e){let{e:s}=e;this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:s}=e;if(this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const t=this._points,e=t.length,s=this.canvas.contextTop;this._saveAndTransform(s),this.oldEnd&&(s.beginPath(),s.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=zn.drawSegment(s,t[e-2],t[e-1]),s.stroke(),s.restore()}}onMouseUp(t){let{e:e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvas.contextTop,e=this._points[0],s=this._points[1];if(this._saveAndTransform(t),t.beginPath(),2===this._points.length&&e.x===s.x&&e.y===s.y){const t=this.width/1e3;e.x-=t,s.x+=t}t.moveTo(e.x,e.y);for(let i=1;i=n&&(i=t[e],a.push(i));return a.push(t[o]),a}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(t){return"M 0 0 Q 0 0 0 0 L 0 0"===on(t)}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const Hn=["left","top","radius"],Gn=["radius","startAngle","endAngle","counterClockwise"];class Nn extends _i{static getDefaults(){return s(s({},super.getDefaults()),Nn.ownDefaults)}constructor(t){super(),Object.assign(this,Nn.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,_t(this.startAngle),_t(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(G)}getRadiusY(){return this.get("radius")*this.get(N)}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([...Gn,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["\n'];{const{radius:e}=this,s=_t(this.startAngle),i=_t(this.endAngle),r=rt(s)*e,n=nt(s)*e,o=rt(i)*e,a=nt(i)*e,h=t>180?1:0,c=this.counterClockwise?0:1;return['\n"]}}static async fromElement(t,e,r){const n=dr(t,this.ATTRIBUTE_NAMES,r),{left:o=0,top:a=0,radius:h=0}=n;return new this(s(s({},i(n,Hn)),{},{radius:h,left:o-h,top:a-h}))}static fromObject(t){return super._fromObject(t)}}t(Nn,"type","Circle"),t(Nn,"cacheProperties",[...ps,...Gn]),t(Nn,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),t(Nn,"ATTRIBUTE_NAMES",["cx","cy","r",...Fi]),tt.setClass(Nn),tt.setSVGClass(Nn);class Un extends Xn{constructor(e){super(e),t(this,"width",10),this.points=[]}drawDot(t){const e=this.addPoint(t),s=this.canvas.contextTop;this._saveAndTransform(s),this.dot(s,e),s.restore()}dot(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()}onMouseDown(t){this.points=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)}_render(){const t=this.canvas.contextTop,e=this.points;this._saveAndTransform(t);for(let s=0;s0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,$n.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(M,n),"number"==typeof o&&this.set(P,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}=ve([{x:t,y:e},{x:s,y:i}]),h=new ot(r+o/2,n+a/2);this.setPositionByOrigin(h,D,D)}_set(t,e){return super._set(t,e),Zn.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;$t(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 ot((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(s({},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["\n')]}static async fromElement(t,e,s){const r=dr(t,this.ATTRIBUTE_NAMES,s),{x1:n=0,y1:o=0,x2:a=0,y2:h=0}=r;return new this([n,o,a,h],i(r,Jn))}static fromObject(t){let{x1:e,y1:r,x2:n,y2:o}=t,a=i(t,Qn);return this._fromObject(s(s({},a),{},{points:[e,r,n,o]}),{extraParam:"points"})}}t($n,"type","Line"),t($n,"cacheProperties",[...ps,...Zn]),t($n,"ATTRIBUTE_NAMES",Fi.concat(Zn)),tt.setClass($n),tt.setSVGClass($n);class to extends _i{static getDefaults(){return s(s({},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["']}}t(to,"type","Triangle"),t(to,"ownDefaults",{width:100,height:100}),tt.setClass(to),tt.setSVGClass(to);const eo=["rx","ry"];class so extends _i{static getDefaults(){return s(s({},super.getDefaults()),so.ownDefaults)}constructor(t){super(),Object.assign(this,so.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(G)}getRy(){return this.get("ry")*this.get(N)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...eo,...t])}_toSVG(){return["\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,w,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,s){const i=dr(t,this.ATTRIBUTE_NAMES,s);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}function io(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),s=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"strokeDiff",void 0),Object.assign(this,oo.ownDefaults),this.setOptions(s),this.points=e;const{left:i,top:r}=s;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(M,i),"number"==typeof r&&this.set(P,r)}isOpen(){return!0}_projectStrokeOnPoints(t){return Ti(this.points,t,this.isOpen())}_calcDimensions(t){t=s({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 ot,strokeOffset:new ot,strokeDiff:new ot};const i=ve(e),r=Ft(s(s({},t),{},{scaleX:1,scaleY:1})),n=ve(this.points.map((t=>bt(t,r,!0)))),o=new ot(this.scaleX,this.scaleY);let a=i.left+i.width/2,h=i.top+i.height/2;return this.exactBoundingBox&&(a-=h*Math.tan(_t(this.skewX)),h-=a*Math.tan(_t(this.skewY))),s(s({},i),{},{pathOffset:new ot(a,h),strokeOffset:new ot(n.left,n.top).subtract(new ot(i.left,i.top)).multiply(o),strokeDiff:new ot(i.width,i.height).subtract(new ot(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=ve(this.points);return new ot(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 ot(e+i/2,s+r/2),D,D)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new ot(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 ot(null!==(e=t.width)&&void 0!==e?e:i,null!==(s=t.height)&&void 0!==s?s:r)}else{var i,r;n=new ot(null!==(i=t.width)&&void 0!==i?i:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return n.multiply(new ot(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===G||t===N)&&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 s(s({},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=o.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r\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;rvoid 0!==t));this._setStyleDeclaration(i,r,n)}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 s(s({},Xt(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]}}t(_o,"_styleProperties",go);const xo=/ +/g,Co=/"/g;function bo(t,e,s,i,r){return"\t\t".concat(function(t,e){let{left:s,top:i,width:r,height:n}=e,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.NUM_FRACTION_DIGITS;const h=Zt(K,t,!1),[c,l,u,d]=[s,i,r,n].map((t=>qt(t,a)));return"')}(t,{left:e,top:s,width:i,height:r}),"\n")}const wo=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let So;class To extends _o{static getDefaults(){return s(s({},super.getDefaults()),To.ownDefaults)}constructor(e,s){super(),t(this,"__charBounds",[]),Object.assign(this,To.ownDefaults),this.setOptions(s),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Qr(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(po)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,s,i,r,n,o;for(let a=0,h=this._textLines.length;a')}_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===J?(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 D:t.textBaseline="middle";break;case"ascender":t.textBaseline=P;break;case"descender":t.textBaseline=E}t.font=this._getFontDeclaration(e,s)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,s=this._textLines.length;et&&(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 e=0,r=this._textLines.length;e=0:ie?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=Zr(i.path,s,i.segmentsInfo);e.renderLeft=r.x-i.pathOffset.x,e.renderTop=r.y-i.pathOffset.y,e.angle=r.angle+(this.pathSide===A?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}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let s=1,i=this._textLines[t].length;s0){let e=i+u+f;"rtl"===this.direction&&(e=this.width-e-p),m&&v&&(t.fillStyle=v,t.fillRect(e,y+o*_+x,p,this.fontSize/15)),f=n.left,p=n.width,m=d,v=g,_=h,x=c}else p+=n.kernedWidth}let C=i+u+f;"rtl"===this.direction&&(C=this.width-C-p),t.fillStyle=g,d&&g&&t.fillRect(C,y+o*_+x,p-n,this.fontSize/15),s+=h}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(",")||To.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 Di(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),s=new Array(e.length),i=["\n"];let r=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return s(s({},super.toObject([...uo,...t])),{},{styles:Ai(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 e in t)"path"===e&&this.setPathInfo(),i=i||s.includes(e),r=r||"path"===e;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,r){const n=dr(t,To.ATTRIBUTE_NAMES,r),o=s(s({},e),n),{textAnchor:a=M,textDecoration:h="",dx:c=0,dy:l=0,top:u=0,left:d=0,fontSize:g=O,strokeWidth:f=1}=o,p=i(o,wo),m=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),s({left:d+c,top:u+l,underline:h.includes("underline"),overline:h.includes("overline"),linethrough:h.includes("line-through"),strokeWidth:0,fontSize:g},p)),v=m.getScaledHeight()/m.height,y=((m.height+m.strokeWidth)*m.lineHeight-m.height)*v,_=m.getScaledHeight()+y;let x=0;return a===D&&(x=m.getScaledWidth()/2),a===A&&(x=m.getScaledWidth()),m.set({left:m.left-x,top:m.top-(_-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:f}),m}static fromObject(t){return this._fromObject(s(s({},t),{},{styles:ji(t.styles||{},t.text)}),{extraParam:"text"})}}t(To,"textLayoutProperties",lo),t(To,"cacheProperties",[...ps,...uo]),t(To,"ownDefaults",fo),t(To,"type","Text"),t(To,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),t(To,"ATTRIBUTE_NAMES",Fi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),yi(To,[class extends Xe{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})}_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",s.join(""),"\n"]}_getSVGTextAndBg(t,e){const s=[],i=[];let r,n=t;this.backgroundColor&&i.push(...bo(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t").concat(ki(t),"")}_setSVGTextLineText(t,e,s,i){const r=this.getHeightOfLine(e),n=this.textAlign.includes(po),o=this._textLines[e];let a,h,c,l,u,d="",g=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let r=0,f=o.length-1;r<=f;r++)u=r===f||this.charSpacing,d+=o[r],c=this.__charBounds[e][r],0===g?(s+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[r])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(e,r),h=this.getCompleteStyleDeclaration(e,r+1),u=Ei(a,h,!0)),u&&(l=this._getStyleDeclaration(e,r),t.push(this._createTextCharSpan(d,l,s,i)),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;lt[e.replace("-","")])).join(" ")}}]),tt.setClass(To),tt.setSVGClass(To);class Oo{constructor(e){t(this,"target",void 0),t(this,"__mouseDownInPlace",!1),t(this,"__dragStartFired",!1),t(this,"__isDraggingOver",!1),t(this,"__dragStartSelection",void 0),t(this,"__dragImageDisposer",void 0),t(this,"_dispose",void 0),this.target=e;const s=[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=()=>{s.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{_.remove()},ne(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,i=this.isActive();if(i&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(i.selectionStart,i.selectionEnd).join(""),n=s({text:e.text,value:r},i);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}return e.abortCursorAnimation(),i}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 es.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;if(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(z,{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)||j;o===j?(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(z,{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 ko=/[ \n\.,;!\?\-]/;class Do extends To{constructor(){super(...arguments),t(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 js({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}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-1;)e++,s--;return t-e}findLineBoundaryRight(t){let e=0,s=t;for(;!/\n/.test(this._text[s])&&s0&&this._reSpace.test(s[t])&&(-1===e||!F.test(s[t-1]))?t-1:t,r=s[i];for(;i>0&&ithis.__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()))}_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;if(t===e)return{selectionStart:i,selectionEnd:i};return{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 ot(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new ot(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(Q),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=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,i,r){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let h=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const s in this.styles[t]){const i=parseInt(s,10);i>=e&&(h=!0,n[i-e]=this.styles[t][s],a&&0===e||delete this.styles[t][s])}let l=!1;for(h&&!a&&(this.styles[t+i]=n,l=!0),(l||o>e)&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:s({},r[i-1])}:c?this.styles[t+i]={0:s({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,r){this.styles||(this.styles={});const n=this.styles[t],o=n?s({},n):{};i||(i=1);for(const t in o){const s=parseInt(t,10);s>=e&&(n[s+i]=o[s],o[s-i]||delete n[s])}if(this._forceClearCache=!0,r){for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=s({},r[i]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=s({},a)}insertNewStyleBlock(t,e,s){const i=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let e=0;e0&&(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;n0?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=M:this._selectionDirection===A&&(this._selectionDirection=M,this.selectionEnd=t),this.selectionStart=s):s>t&&s{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,"; 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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const s=()=>{this.updateFromTextArea(),this.fire(z),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void s();const i=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,n=i.length,a=this.selectionStart,h=this.selectionEnd,c=a!==h;let l,u,d,g,f=n-r;const m=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),v=a>m.selectionStart;c?(u=this._text.slice(a,h),f+=h-a):nl[0]))),c?(d=a,g=h):v?(d=h-u.length,g=h):(d=h,g=h+u.length),this.removeStyleFromTo(d,g)),y.length){const{copyPasteData:t}=p();e&&y.join("")===t.copiedText&&!o.disableStyleCopyPaste&&(l=t.copiedTextStyle),this.insertNewStyleBlock(y,a,l)}s()}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}=p();t.copiedText=this.getSelectedText(),o.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;ae){r=!0;const t=n-i,s=n,h=Math.abs(t-e);o=Math.abs(s-e)=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===A);if(e.shiftKey?this.moveCursorWithShift(s):this.moveCursorWithoutShift(s),0!==s){const t=this.text.length;this.selectionStart=gs(0,this.selectionStart,t),this.selectionEnd=gs(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===M?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;if(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=M,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===A&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=M,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===M&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=A,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=A,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Po=t=>!!t.button;class Eo extends Mo{constructor(){super(...arguments),t(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new Oo(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),me(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e:e}=t;this.canvas&&this.editable&&!Po(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e:e}=t;this.canvas&&this.editable&&!Po(e)&&(this.selected=this===this.canvas._activeObject)}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||Po(e)||i||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}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(wt(this.calcTransformMatrix())).add(new ot(-this._getLeftOffset(),-this._getTopOffset()));let s=0,i=0,r=0;for(let t=0;t0&&(i+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,a=this.__charBounds[r];for(let t=0;t0&&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)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_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 t=0;t0?s:0)};return"rtl"===this.direction&&(this.textAlign===A||this.textAlign===po||this.textAlign===vo?a.left*=-1:this.textAlign===M||this.textAlign===mo?a.left=n-(s>0?s:0):this.textAlign!==D&&this.textAlign!==yo||(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(po),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 e=h;e<=c;e++){const i=this._getLineLeftOffset(e)||0;let r=this.getHeightOfLine(e),o=0,a=0,d=0;if(e===h&&(a=this.__charBounds[h][l].left),e>=h&&e1)&&(r/=this.lineHeight);let g=s.left+i+a,f=r,p=0;const m=d-a;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",f=1,p=r):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===A||this.textAlign===po||this.textAlign===vo?g=this.width-g-m:this.textAlign===M||this.textAlign===mo?g=s.left+i-d:this.textAlign!==D&&this.textAlign!==yo||(g=s.left+i-d)),t.fillRect(g,s.top+s.topOffset+p,m,f),s.topOffset+=o}}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,K)}_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()}}t(Bo,"ownDefaults",Io),t(Bo,"type","IText"),tt.setClass(Bo),tt.setClass(Bo,"i-text");class Xo extends Bo{static getDefaults(){return s(s({},super.getDefaults()),Xo.ownDefaults)}constructor(t,e){super(t,s(s({},Xo.ownDefaults),e))}static createControls(){return{controls:mi()}}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(po)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,s=0,i=0;const r={};for(let n=0;n0?(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 t in a)for(const i in a[t]){const n=parseInt(i,10);if(n>=s&&(!r||n{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;n3&&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;vp&&!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 t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}t(Xo,"type","Textbox"),t(Xo,"textLayoutProperties",[...Bo.textLayoutProperties,"width"]),t(Xo,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tt.setClass(Xo);class Yo extends Cr{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}=ve(xr(s,i)),a=new ot(n,o);if(i.absolutePositioned){return{center:Te(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 ot,correction:i=new ot}=this.calcBoundingBox(e,t)||{};return{center:s.add(r),correction:i.subtract(r),size:a}}return{center:s.getRelativeCenterPoint().add(r),size:a}}}}t(Yo,"type","clip-path"),tt.setClass(Yo);class Wo extends Cr{getInitialSize(t,e){let{target:s}=t,{size:i}=e;return new ot(s.width||i.x,s.height||i.y)}}t(Wo,"type","fixed"),tt.setClass(Wo);class Vo extends Or{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 zo extends Mr{static getDefaults(){return s(s({},super.getDefaults()),zo.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,zo.ownDefaults),this.setOptions(e);const{left:s,top:i,layoutManager:r}=e;this.groupInit(t,{left:s,top:i,layoutManager:null!=r?r:new Vo})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),s=0;s{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)))?(a("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)})),t===yr?s.forEach((t=>{t._onAfterObjectsChange(vr,e)})):s.forEach((t=>{t._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const r=s(s({hasControls:!1},i),{},{forActiveSelection:!0});for(let e=0;e{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 Go{constructor(){let{tileSize:e=o.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),t(this,"resources",{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const s=vt({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.originalWidth||0,originalHeight:e.height||e.originalHeight||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 No;function Uo(){const{WebGLProbe:t}=p();return t.queryWebGL(pt()),o.enableGLFiltering&&t.isSupported(o.textureSize)?new Go({tileSize:o.textureSize}):new Ho}function qo(){return!No&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(No=Uo()),No}function Ko(t){No=t}const Jo=["filters","resizeFilter","src","crossOrigin","type"],Qo=["cropX","cropY"];class Zo extends _i{static getDefaults(){return s(s({},super.getDefaults()),Zo.ownDefaults)}constructor(e,s){super(),t(this,"_lastScaleX",1),t(this,"_lastScaleY",1),t(this,"_filterScalingX",1),t(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Zo.ownDefaults),this.setOptions(s),this.cacheKey="texture".concat(ft()),this.setElement("string"==typeof e?(this.canvas&&ne(this.canvas.getElement())||m()).getElementById(e):e,s)}getElement(){return this._element}setElement(t){let e=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(e),t.classList.add(Zo.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=qo(!1);e instanceof Go&&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&&p().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())})),s(s({},super.toObject([...Qo,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width\n','\t\n',"\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,n=['\t\n')],this.fill=t}return r=this.paintFirst!==K?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 Rt(t,{crossOrigin:e,signal:s}).then((t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)}))}toString(){return'#')}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=vt(n),{width:a,height:h}=n;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=r,qo().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=vt({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);qo().applyFilters(t,this._originalElement,s,i,this._element),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.naturalWidth||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=Jt(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===j&&t.alignY===j?(a=e/n,h=s/o):("meet"===t.meetOrSlice&&(a=h=Pr(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=Er(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:r,resizeFilter:n,src:o,crossOrigin:a,type:h}=t,c=i(t,Jo);return Promise.all([Rt(o,s(s({},e),{},{crossOrigin:a})),r&&It(r,e),n&&It([n],e),Bt(c,e)]).then((t=>{let[e,i=[],[r]=[],n={}]=t;return new this(e,s(s({},c),{},{src:o,filters:i,resizeFilter:r},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 Rt(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=dr(t,this.ATTRIBUTE_NAMES,s);return this.fromURL(i["xlink:href"],e,i).catch((t=>(a("log","Unable to parse Image",t),null)))}}function $o(t){if(!Ke.test(t.nodeName))return{};const e=t.getAttribute("viewBox");let s,i,r=1,n=1,o=0,a=0;const h=t.getAttribute("width"),c=t.getAttribute("height"),l=t.getAttribute("x")||0,u=t.getAttribute("y")||0,d=!(e&&Qe.test(e)),g=!h||!c||"100%"===h||"100%"===c;let f="",p=0,m=0;if(d&&(l||u)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") ",s=(t.getAttribute("transform")||"")+f,t.setAttribute("transform",s),t.removeAttribute("x"),t.removeAttribute("y")),d&&g)return{width:0,height:0};const v={width:0,height:0};if(d)return v.width=Kt(h),v.height=Kt(c),v;const y=e.match(Qe);o=-parseFloat(y[1]),a=-parseFloat(y[2]);const _=parseFloat(y[3]),x=parseFloat(y[4]);v.minX=o,v.minY=a,v.viewBoxWidth=_,v.viewBoxHeight=x,g?(v.width=_,v.height=x):(v.width=Kt(h),v.height=Kt(c),r=v.width/_,n=v.height/x);const C=Jt(t.getAttribute("preserveAspectRatio")||"");if(C.alignX!==j&&("meet"===C.meetOrSlice&&(n=r=r>n?n:r),"slice"===C.meetOrSlice&&(n=r=r>n?r:n),p=v.width-_*r,m=v.height-x*r,"Mid"===C.alignX&&(p/=2),"Mid"===C.alignY&&(m/=2),"Min"===C.alignX&&(p=0),"Min"===C.alignY&&(m=0)),1===r&&1===n&&0===o&&0===a&&0===l&&0===u)return v;if((l||u)&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") "),s=f+" matrix("+r+" 0 0 "+n+" "+(o*r+p)+" "+(a*n+m)+") ","svg"===t.nodeName){for(i=t.ownerDocument.createElementNS(ze,"g");t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i)}else i=t,i.removeAttribute("x"),i.removeAttribute("y"),s=i.getAttribute("transform")+s;return i.setAttribute("transform",s),v}t(Zo,"type","Image"),t(Zo,"cacheProperties",[...ps,...Qo]),t(Zo,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),t(Zo,"CSS_CANVAS","canvas-img"),t(Zo,"ATTRIBUTE_NAMES",[...Fi,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),tt.setClass(Zo),tt.setSVGClass(Zo);const ta=t=>t.tagName.replace("svg:",""),ea=Ye(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);function sa(t,e){let s,i,r,n,o=[];for(r=0,n=e.length;r{const s=r.getAttribute(t);!e.hasAttribute(t)&&s&&e.setAttribute(t,s)})),!e.children.length)){const t=r.cloneNode(!0);for(;t.firstChild;)e.appendChild(t.firstChild)}e.removeAttribute(ra)}const oa=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"];function aa(t){const e=t.getElementsByTagName("style");let i,r;const n={};for(i=0,r=e.length;is.length>1&&t.trim())).forEach((t=>{if((t.match(/{/g)||[]).length>1&&t.trim().startsWith("@"))return;const e=t.split("{"),o={},a=e[1].trim().split(";").filter((function(t){return t.trim()}));for(i=0,r=a.length;i{""!==(t=t.replace(/^svg/i,"").trim())&&(n[t]=s(s({},n[t]||{}),o))}))}))}return n}const ha=t=>tt.getSVGClass(ta(t).toLowerCase());class ca{constructor(t,e,s,i,r){this.elements=t,this.options=e,this.reviver=s,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=i,this.clipPaths=r,this.gradientDefs=function(t){const e=sa(t,oa),s={};let i=e.length;for(;i--;){const r=e[i];r.getAttribute("xlink:href")&&na(t,r);const n=r.getAttribute("id");n&&(s[n]=r)}return s}(i),this.cssRules=aa(i)}parse(){return Promise.all(this.elements.map((t=>this.createObject(t))))}async createObject(t){const e=ha(t);if(e){const s=await e.fromElement(t,this.options,this.cssRules);return this.resolveGradient(s,t,K),this.resolveGradient(s,t,J),s instanceof Zo&&s._originalElement?ln(s,s.parsePreserveAspectRatioAttribute()):ln(s),await this.resolveClipPath(s,t),this.reviver&&this.reviver(t,s),s}return null}extractPropertyDefinition(t,e,s){const i=t[e],r=this.regexUrl;if(!r.test(i))return;r.lastIndex=0;const n=r.exec(i)[1];return r.lastIndex=0,s[n]}resolveGradient(t,e,i){const r=this.extractPropertyDefinition(t,i,this.gradientDefs);if(r){const n=e.getAttribute(i+"-opacity"),o=Rn.fromElement(r,t,s(s({},this.options),{},{opacity:n}));t.set(i,o)}}async resolveClipPath(t,e,s){const i=this.extractPropertyDefinition(t,"clipPath",this.clipPaths);if(i){const r=wt(t.calcTransformMatrix()),n=i[0].parentElement;let o=e;for(;!s&&o.parentElement&&o.getAttribute("clip-path")!==t.clipPath;)o=o.parentElement;o.parentElement.appendChild(n);const a=or("".concat(o.getAttribute("transform")||""," ").concat(n.getAttribute("originalTransform")||""));n.setAttribute("transform","matrix(".concat(a.join(","),")"));const h=await Promise.all(i.map((t=>ha(t).fromElement(t,this.options,this.cssRules).then((t=>(ln(t),t.fillRule=t.clipRule,delete t.clipRule,t)))))),c=1===h.length?h[0]:new Mr(h),l=St(r,c.calcTransformMatrix());c.clipPath&&await this.resolveClipPath(c,o,n.getAttribute("clip-path")?o:void 0);const{scaleX:u,scaleY:d,angle:g,skewX:f,translateX:p,translateY:m}=kt(l);c.set({flipX:!1,flipY:!1}),c.set({scaleX:u,scaleY:d,angle:g,skewX:f,skewY:0}),c.setPositionByOrigin(new ot(p,m),D,D),t.clipPath=c}else delete t.clipPath}}const la=t=>qe.test(ta(t)),ua=()=>({objects:[],elements:[],options:{},allElements:[]});async function da(t,e){let{crossOrigin:i,signal:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r&&r.aborted)return a("log",new c("parseSVGDocument")),ua();const n=t.documentElement;!function(t){const e=sa(t,["use","svg:use"]),s=["x","y","xlink:href","href","transform"];for(const i of e){const e=i.attributes,r={};for(const t of e)t.value&&(r[t.name]=t.value);const n=(r["xlink:href"]||r.href||"").slice(1);if(""===n)return;const o=t.getElementById(n);if(null===o)return;let a=o.cloneNode(!0);const h=a.attributes,c={};for(const t of h)t.value&&(c[t.name]=t.value);const{x:l=0,y:u=0,transform:d=""}=r,g="".concat(d," ").concat(c.transform||""," translate(").concat(l,", ").concat(u,")");if($o(a),/^svg$/i.test(a.nodeName)){const t=a.ownerDocument.createElementNS(ze,"g");Object.entries(c).forEach((e=>{let[s,i]=e;return t.setAttributeNS(ze,s,i)})),t.append(...a.childNodes),a=t}for(const t of e){if(!t)continue;const{name:e,value:i}=t;if(!s.includes(e))if("style"===e){const t={};cr(i,t),Object.entries(c).forEach((e=>{let[s,i]=e;t[s]=i})),cr(c.style||"",t);const s=Object.entries(t).map((t=>t.join(":"))).join(";");a.setAttribute(e,s)}else!c[e]&&a.setAttribute(e,i)}a.setAttribute("transform",g),a.setAttribute("instantiated_by_use","1"),a.removeAttribute("id"),i.parentNode.replaceChild(a,i)}}(t);const o=Array.from(n.getElementsByTagName("*")),h=s(s({},$o(n)),{},{crossOrigin:i,signal:r}),l=o.filter((t=>($o(t),la(t)&&!function(t){let e=t;for(;e&&(e=e.parentElement);)if(e&&e.nodeName&&ea.test(ta(e))&&!e.getAttribute("instantiated_by_use"))return!0;return!1}(t))));if(!l||l&&!l.length)return s(s({},ua()),{},{options:h,allElements:o});const u={};o.filter((t=>"clipPath"===ta(t))).forEach((t=>{t.setAttribute("originalTransform",t.getAttribute("transform")||"");const e=t.getAttribute("id");u[e]=Array.from(t.getElementsByTagName("*")).filter((t=>la(t)))}));const d=new ca(l,h,e,t,u);return{objects:await d.parse(),elements:l,options:h,allElements:o}}function ga(t,e,s){return da((new(v().DOMParser)).parseFromString(t.trim(),"text/xml"),e,s)}function fa(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((e,i)=>{cn(t.replace(/^\n\s*/,"").trim(),{onComplete:t=>{const s=t.responseXML;s&&e(s),i()},signal:s.signal})})).then((t=>da(t,e,s))).catch((()=>ua()))}const pa=W,ma=t=>function(e,s,i){const{points:r,pathOffset:n}=i;return new ot(r[t]).subtract(n).transform(St(i.getViewportTransform(),i.calcTransformMatrix()))},va=(t,e,s,i)=>{const{target:r,pointIndex:n}=e,o=r,a=Te(new ot(s,i),void 0,o.calcOwnMatrix());return o.points[n]=a.add(o.pathOffset),o.setDimensions(),!0},ya=(t,e)=>function(i,r,n,o){const a=r.target,h=new ot(a.points[(t>0?t:a.points.length)-1]),c=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()),l=e(i,s(s({},r),{},{pointIndex:t}),n,o),u=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()).subtract(c);return a.left-=u.x,a.top-=u.y,l},_a=t=>Ys(pa,ya(t,va));const xa=(t,e,s)=>{const{path:i,pathOffset:r}=t,n=i[e];return new ot(n[s]-r.x,n[s+1]-r.y).transform(St(t.getViewportTransform(),t.calcTransformMatrix()))};function Ca(t,e,s){const{commandIndex:i,pointIndex:r}=this;return xa(s,i,r)}function ba(t,e,i,r){const{target:n}=e,{commandIndex:o,pointIndex:a}=this,h=((t,e,s,i,r)=>{const{path:n,pathOffset:o}=t,a=n[(i>0?i:n.length)-1],h=new ot(a[r],a[r+1]),c=h.subtract(o).transform(t.calcOwnMatrix()),l=Te(new ot(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})(n,i,r,o,a);return De(this.actionName,s(s({},Le(t,e,i,r)),{},{commandIndex:o,pointIndex:a})),h}class wa extends Gs{constructor(t){super(t)}render(t,e,i,r,n){const o=s(s({},r),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,i,o,n)}}class Sa extends wa{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=xa(r,h,c);if("Q"===l){const i=xa(r,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,s)}else t.moveTo(e,s);t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,s,i,r)}}const Ta=(t,e,i,r,n,o)=>new(i?Sa:wa)(s(s({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:Ca,actionHandler:ba,connectToCommandIndex:n,connectToPointIndex:o},r),i?r.controlPointStyle:r.pointStyle));var Oa=Object.freeze({__proto__:null,changeWidth:Vs,createObjectDefaultControls:fi,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)]=Ta(r,t.length-2,!1,e)),n){case"C":s["c_".concat(r,"_C_CP_1")]=Ta(r,1,!0,e,r-1,(t=>"C"===t?5:"Q"===t?3:1)(i)),s["c_".concat(r,"_C_CP_2")]=Ta(r,3,!0,e,r,5);break;case"Q":s["c_".concat(r,"_Q_CP_1")]=Ta(r,1,!0,e,r,3)}i=n})),s},createPolyActionHandler:_a,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={};for(let r=0;r<("number"==typeof t?t:t.points.length);r++)i["p".concat(r)]=new Gs(s({actionName:pa,positionHandler:ma(r),actionHandler:_a(r)},e));return i},createPolyPositionHandler:ma,createResizeControls:pi,createTextboxDefaultControls:mi,dragHandler:Be,factoryPolyActionHandler:ya,getLocalPoint:Ie,polyActionHandler:va,renderCircleControl:zs,renderSquareControl:Hs,rotationStyleHandler:Ns,rotationWithSnapping:Us,scaleCursorStyleHandler:Qs,scaleOrSkewActionName:li,scaleSkewCursorStyleHandler:ui,scalingEqually:$s,scalingX:ti,scalingXOrSkewingY:di,scalingY:ei,scalingYOrSkewingX:gi,skewCursorStyleHandler:ni,skewHandlerX:ai,skewHandlerY:hi,wrapWithFireEvent:Ys,wrapWithFixedAnchor:Ws});const ka=t=>void 0!==t.webgl,Da=(t,e)=>{const s=vt({width:t,height:e}),i=pt().getContext("webgl"),r={imageBuffer:new ArrayBuffer(t*e*4)},n={destinationWidth:t,destinationHeight:e,targetCanvas:s};let o;o=v().performance.now(),Go.prototype.copyGLTo2D.call(r,i,n);const a=v().performance.now()-o;o=v().performance.now(),Go.prototype.copyGLTo2DPutImageData.call(r,i,n);return a>v().performance.now()-o},Ma="precision highp float",Pa="\n ".concat(Ma,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),Ea=["type"],Aa=["type"],ja=new RegExp(Ma,"g");class Fa{get type(){return this.constructor.type}constructor(){let t=i(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Ea);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Pa}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"}}=p();"highp"!==i&&(e=e.replace(ja,Ma.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 h("Vertex, fragment shader or program creation error");if(t.shaderSource(r,s),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new h("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 h("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 h('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;r1){const s=t.destinationWidth,i=t.destinationHeight;t.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){ka(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=vt({width:e,height:s});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return s({type:this.type},t.reduce(((t,e)=>(t[e]=this[e],t)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(i(t,Aa))}}t(Fa,"type","BaseFilter"),t(Fa,"uniformLocations",[]);const La={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 Ra extends Fa{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(La[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t;const s=new Ut(this.color).getSource(),i=s[0]*this.alpha,r=s[1]*this.alpha,n=s[2]*this.alpha,o=1-this.alpha;for(let t=0;tnew this(s(s({},o),{},{image:t}))))}}t(Xa,"type","BlendImage"),t(Xa,"defaults",{mode:"multiply",alpha:1}),t(Xa,"uniformLocations",["uTransformMatrix","uImage"]),tt.setClass(Xa);class Ya extends Fa{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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n "}applyTo(t){ka(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){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:s,filterBackend:{resources:i}}=t;const{width:r,height:n}=s;i.blurLayer1||(i.blurLayer1=pt(),i.blurLayer2=pt());const o=i.blurLayer1,a=i.blurLayer2;o.width===r&&o.height===n||(a.width=o.width=r,a.height=o.height=n);const h=o.getContext("2d"),c=a.getContext("2d"),l=15,u=.06*this.blur*.5;let d,g,f,p;for(h.putImageData(s,0,0),c.clearRect(0,0,r,n),p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*r+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,f,d),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);for(p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*n+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,d,f),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);e.drawImage(o,0,0);const m=e.getImageData(0,0,o.width,o.height);return h.globalAlpha=1,h.clearRect(0,0,o.width,o.height),m}sendUniformData(t,e){const s=this.chooseRightDelta();t.uniform2fv(e.uDelta,s)}isNeutralState(){return 0===this.blur}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const s=t*this.blur*.12;return this.horizontal?e[0]=s:e[1]=s,e}}t(Ya,"type","Blur"),t(Ya,"defaults",{blur:0}),t(Ya,"uniformLocations",["uDelta"]),tt.setClass(Ya);class Wa extends Fa{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 t=0;t0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){ka(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((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=>tt.getClass(t.type).fromObject(t,e)))).then((t=>new this({subFilters:t})))}}t(Qa,"type","Composed"),tt.setClass(Qa);class Za extends Fa{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 t=0;t=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 s(s({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}t(th,"type","Convolute"),t(th,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),t(th,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tt.setClass(th);const eh="Gamma";class sh extends Fa{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 t=0;t<256;t++)o.r[t]=255*Math.pow(t/255,i),o.g[t]=255*Math.pow(t/255,r),o.b[t]=255*Math.pow(t/255,n);for(let t=0;tr[0]&&i>r[1]&&o>r[2]&&s"\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){ka(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=pt());const m=u.sliceByTwo;(m.width<1.5*e||m.height=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++y1&&n<-1||(l=2*n*n*n-3*n*n+1,l>0&&(s=4*(t+i*e),v+=l*c[s+3],g+=l,c[s+3]<255&&(l=l*c[s+3]/250),f+=l*c[s],p+=l*c[s+1],m+=l*c[s+2],d+=l))}}u[r]=f/d,u[r+1]=p/d,u[r+2]=m/d,u[r+3]=v/g}return l}}t(lh,"type","Resize"),t(lh,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),t(lh,"uniformLocations",["uDelta","uTaps"]),tt.setClass(lh);class uh extends Fa{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 t=0;t=0)continue;s[i]=t[i]}return s}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i=0||{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function r(t,e){return e||(e=t.slice(0)),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}class n{constructor(){t(this,"browserShadowBlurConstant",1),t(this,"DPI",96),t(this,"devicePixelRatio","undefined"!=typeof window?window.devicePixelRatio:1),t(this,"perfLimitSizeTotal",2097152),t(this,"maxCacheSideLimit",4096),t(this,"minCacheSideLimit",256),t(this,"disableStyleCopyPaste",!1),t(this,"enableGLFiltering",!0),t(this,"textureSize",4096),t(this,"forceGLPutImageData",!1),t(this,"cachesBoundsOfCurve",!1),t(this,"fontPaths",{}),t(this,"NUM_FRACTION_DIGITS",4)}}const o=new class extends n{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=s(s({},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 n,s=(null==t?void 0:t.reduce(((t,s)=>(t[s]=e[s],t)),{}))||e;this.configure(s)}},a=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis.testPrecision(e,t))),e.getExtension("WEBGL_lose_context").loseContext(),a("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const d={};let g;const f=t=>{g=t},p=()=>g||(g={document:document,window:window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new u,dispose(){},copyPasteData:d}),m=()=>p().document,v=()=>p().window,y=()=>{var t;return Math.max(null!==(t=o.devicePixelRatio)&&void 0!==t?t:v().devicePixelRatio,1)};const _=new class{constructor(){t(this,"charWidthsCache",{}),t(this,"boundsOfCurveCache",{})}getFontCache(t){let{fontFamily:e,fontStyle:s,fontWeight:i}=t;e=e.toLowerCase(),this.charWidthsCache[e]||(this.charWidthsCache[e]={});const r=this.charWidthsCache[e],n="".concat(s.toLowerCase(),"_").concat((i+"").toLowerCase());return r[n]||(r[n]={}),r[n]}clearFontCache(t){(t=(t||"").toLowerCase())?this.charWidthsCache[t]&&delete this.charWidthsCache[t]:this.charWidthsCache={}}limitDimsByArea(t){const{perfLimitSizeTotal:e}=o,s=Math.sqrt(e*t);return[Math.floor(s),Math.floor(e/s)]}};const x="6.5.2";function C(){}const b=Math.PI/2,w=2*Math.PI,S=Math.PI/180,T=Object.freeze([1,0,0,1,0,0]),O=16,k=.4477152502,D="center",M="left",P="top",E="bottom",A="right",j="none",F=/\r?\n/,L="moving",R="scaling",I="rotating",B="rotate",X="skewing",Y="resizing",W="modifyPoly",V="modifyPath",z="changed",H="scale",G="scaleX",N="scaleY",U="skewX",q="skewY",K="fill",J="stroke",Q="modified",Z="json",$="svg";const tt=new class{constructor(){this[Z]=new Map,this[$]=new Map}has(t){return this[Z].has(t)}getClass(t){const e=this[Z].get(t);if(!e)throw new h("No class registered for ".concat(t));return e}setClass(t,e){e?this[Z].set(e,t):(this[Z].set(t.type,t),this[Z].set(t.type.toLowerCase(),t))}getSVGClass(t){return this[$].get(t)}setSVGClass(t,e){this[$].set(null!=e?e:t.type.toLowerCase(),t)}};const et=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 st{constructor(){t(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!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 t in this.__eventListeners)this._removeEventListener(t);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 t=0;t{const s=t.indexOf(e);return-1!==s&&t.splice(s,1),t},rt=t=>{if(0===t)return 1;switch(Math.abs(t)/b){case 1:case 3:return 0;case 2:return-1}return Math.cos(t)},nt=t=>{if(0===t)return 0;const e=t/b,s=Math.sign(t);switch(e){case 1:return s;case 2:return 0;case 3:return-s}return Math.sin(t)};class ot{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 ot(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new ot(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new ot(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new ot(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new ot(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new ot(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new ot(this.x/t.x,this.y/t.y)}scalarDivide(t){return new ot(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.xt.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 ot(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 ot(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new ot(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 ot(this.x,this.y)}rotate(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:at;const s=nt(t),i=rt(t),r=this.subtract(e);return new ot(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 ot(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 at=new ot(0,0),ht=t=>!!t&&Array.isArray(t._objects);function ct(e){class s extends e{constructor(){super(...arguments),t(this,"_objects",[])}_onObjectAdded(t){}_onObjectRemoved(t){}_onStackOrderChanged(t){}add(){for(var t=arguments.length,e=new Array(t),s=0;sthis._onObjectAdded(t))),i}insertAt(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;ithis._onObjectAdded(t))),this._objects.length}remove(){const t=this._objects,e=[];for(var s=arguments.length,i=new Array(s),r=0;r{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;st.isType(...e)))}item(t){return this._objects[t]}isEmpty(){return 0===this._objects.length}size(){return this._objects.length}contains(t,e){return!!this._objects.includes(t)||!!e&&this._objects.some((e=>e instanceof s&&e.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])&&(it(this._objects,t),this._objects.unshift(t),this._onStackOrderChanged(t),!0)}bringObjectToFront(t){return!(!t||t===this._objects[this._objects.length-1])&&(it(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 it(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 it(this._objects,t),this._objects.splice(i,0,t),this._onStackOrderChanged(t),!0}return!1}moveObjectTo(t,e){return t!==this._objects[e]&&(it(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;s1&&void 0!==arguments[1]?arguments[1]:{};const o=[],a=new ot(e,s),h=a.add(new ot(i,r));for(let t=this._objects.length-1;t>=0;t--){const e=this._objects[t];e.selectable&&e.visible&&(n&&e.intersectsWithRect(a,h)||e.isContainedWithinRect(a,h)||n&&e.containsPoint(a)||n&&e.containsPoint(h))&&o.push(e)}return o}}return s}class lt extends st{_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 ut(t){return v().requestAnimationFrame(t)}function dt(t){return v().cancelAnimationFrame(t)}let gt=0;const ft=()=>gt++,pt=()=>{const t=m().createElement("canvas");if(!t||void 0===t.getContext)throw new h("Failed to create `canvas` element");return t},mt=()=>m().createElement("img"),vt=t=>{const e=pt();return e.width=t.width,e.height=t.height,e},yt=(t,e,s)=>t.toDataURL("image/".concat(e),s),_t=t=>t*S,xt=t=>t/S,Ct=t=>t.every(((t,e)=>t===T[e])),bt=(t,e,s)=>new ot(t).transform(e,s),wt=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 ot(t[4],t[5]).transform(s,!0);return s[4]=-i,s[5]=-r,s},St=(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]],Tt=(t,e)=>t.reduceRight(((t,s)=>s&&t?St(s,t,e):s||t),void 0)||T.concat(),Ot=t=>{let[e,s]=t;return Math.atan2(s,e)},kt=t=>{const e=Ot(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:xt(e),scaleX:i,scaleY:r,skewX:xt(n),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},Dt=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function Mt(){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=_t(t),r=rt(i),n=nt(i);return[r,n,-n,r,e?e-(r*e-n*s):0,s?s-(n*e+r*s):0]}const Pt=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},Et=t=>Math.tan(_t(t)),At=t=>[1,0,Et(t),1,0,0],jt=t=>[1,Et(t),0,1,0,0],Ft=t=>{let{scaleX:e=1,scaleY:s=1,flipX:i=!1,flipY:r=!1,skewX:n=0,skewY:o=0}=t,a=Pt(i?-e:e,r?-s:s);return n&&(a=St(a,At(n),!0)),o&&(a=St(a,jt(o),!0)),a},Lt=t=>{const{translateX:e=0,translateY:s=0,angle:i=0}=t;let r=Dt(e,s);i&&(r=St(r,Mt({angle:i})));const n=Ft(t);return Ct(n)||(r=St(r,n)),r},Rt=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 c("loadImage"));const n=mt();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 h("Error loading ".concat(n.src)))},s&&(n.crossOrigin=s),n.src=t):a()}))},It=function(t){let{signal:e,reviver:s=C}=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=>tt.getClass(t.type).fromObject(t,{signal:e}).then((e=>(s(t,e),n.push(e),e)))))).then(i).catch((t=>{n.forEach((t=>{t.dispose&&t.dispose()})),r(t)})).finally((()=>{e&&e.removeEventListener("abort",r)}))}))},Bt=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&&tt.has(t.type)?It([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)}))}))},Xt=function(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).reduce(((e,s)=>(s in t&&(e[s]=t[s]),e)),{})},Yt=(t,e)=>Object.keys(t).reduce(((s,i)=>(e(t[i],i,t)&&(s[i]=t[i]),s)),{}),Wt={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"},Vt=(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),zt=(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+(e0&&void 0!==arguments[0]?arguments[0]:"1";return parseFloat(t)/(t.endsWith("%")?100:1)},Gt=t=>Math.min(Math.round(t),255).toString(16).toUpperCase().padStart(2,"0"),Nt=t=>{let[e,s,i,r=1]=t;const n=Math.round(.3*e+.59*s+.11*i);return[n,n,n,r]};class Ut{constructor(e){if(t(this,"isUnrecognised",!1),e)if(e instanceof Ut)this.setSource([...e._source]);else if(Array.isArray(e)){const[t,s,i,r=1]=e;this.setSource([t,s,i,r])}else this.setSource(this._tryParsingColor(e));else this.setSource([0,0,0,1])}_tryParsingColor(t){return(t=t.toLowerCase())in Wt&&(t=Wt[t]),"transparent"===t?[255,255,255,0]:Ut.sourceFromHex(t)||Ut.sourceFromRgb(t)||Ut.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,s]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(s,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,s]=zt(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(s,"%)")}toHsla(){const[t,e,s,i]=zt(...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(Gt(t)).concat(Gt(e)).concat(Gt(s)).concat(Gt(Math.round(255*i)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Nt(this.getSource())),this}toBlackWhite(t){const[e,,,s]=Nt(this.getSource()),i=e<(t||127)?0:255;return this.setSource([i,i,i,s]),this}overlayWith(t){t instanceof Ut||(t=new Ut(t));const e=this.getSource(),s=t.getSource(),[i,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 Ut.fromRgba(t)}static fromRgba(t){return new Ut(Ut.sourceFromRgb(t))}static sourceFromRgb(t){const e=t.match(/^rgba?\(\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d{0,3}(?:\.\d+)?%?)\s*)?\)$/i);if(e){const[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,Ht(e[4])]}}static fromHsl(t){return Ut.fromHsla(t)}static fromHsla(t){return new Ut(Ut.sourceFromHsl(t))}static sourceFromHsl(t){const e=t.match(/^hsla?\(\s*([+-]?\d{0,3}(?:\.\d+)?(?:deg|turn|rad)?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*[\s|,]\s*(\d{0,3}(?:\.\d+)?%?)\s*(?:\s*[,/]\s*(\d*(?:\.\d+)?%?)\s*)?\)$/i);if(!e)return;const s=(Ut.parseAngletoDegrees(e[1])%360+360)%360/360,i=parseFloat(e[2])/100,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=Vt(e,t,s+1/3),o=Vt(e,t,s),a=Vt(e,t,s-1/3)}return[Math.round(255*n),Math.round(255*o),Math.round(255*a),Ht(e[4])]}static fromHex(t){return new Ut(Ut.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let s;s=e.length<=4?e.split("").map((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")?xt(s):e.includes("turn")?360*s:s}}const qt=(t,e)=>parseFloat(Number(t).toFixed(e)),Kt=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;const s=/\D{0,2}$/.exec(t),i=parseFloat(t),r=o.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}},Jt=t=>{const[e,s]=t.trim().split(" "),[i,r]=(n=e)&&n!==j?[n.slice(1,4),n.slice(5,8)]:n===j?[n,n]:["Mid","Mid"];var n;return{meetOrSlice:s||"meet",alignX:i,alignY:r}},Qt=t=>"matrix("+t.map((t=>qt(t,o.NUM_FRACTION_DIGITS))).join(" ")+")",Zt=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 Ut(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,'" '):"")},$t=t=>!!t&&void 0!==t.toLive,te=t=>!!t&&"function"==typeof t.toObject,ee=t=>!!t&&void 0!==t.offsetX&&"source"in t,se=t=>!!t&&"multiSelectionStacking"in t;function ie(t){const e=t&&re(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 re=t=>t.ownerDocument||null,ne=t=>{var e;return(null===(e=t.ownerDocument)||void 0===e?void 0:e.defaultView)||null},oe=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))},ae=(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 he(t){return void 0!==t.onselectstart&&(t.onselectstart=()=>!1),t.style.userSelect=j,t}class ce{constructor(e){t(this,"_originalCanvasStyle",void 0),t(this,"lower",void 0);const s=this.createLowerCanvas(e);this.lower={el:s,ctx:s.getContext("2d")}}createLowerCanvas(t){const e=(s=t)&&void 0!==s.getContext?t:t&&m().getElementById(t)||pt();var s;if(e.hasAttribute("data-fabric"))throw new h("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;oe(s,i,t,e)}setCSSDimensions(t){ae(this.lower.el,t)}calcOffset(){return function(t){var e;const s=t&&re(t),i={left:0,top:0};if(!s)return i;const r=(null===(e=ne(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=ie(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(){p().dispose(this.lower.el),delete this.lower}}const le={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...T]};class ue extends(ct(lt)){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 ue.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}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new ce(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;i0&&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&&(a("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?y():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:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e){const e=s({width:this.width,height:this.height},t);this.elements.setDimensions(e,this.getRetinaScaling()),this.hasLostContext=!0,this.width=e.width,this.height=e.height}i||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=bt(t,wt(i));i[0]=e,i[3]=e;const n=bt(r,i);i[4]+=s.x-n.x,i[5]+=s.y-n.y,this.setViewportTransform(i)}setZoom(t){this.zoomToPoint(new ot(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 ot(-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=ut((()=>this.renderAndReset())))}calcViewportBoundaries(){const t=this.width,e=this.height,s=wt(this.viewportTransform),i=bt({x:0,y:0},s),r=bt({x:t,y:e},s),n=i.min(r),o=i.max(r);return this.vptCoords={tl:n,tr:new ot(o.x,n.y),bl:new ot(n.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&(dt(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const s=this.viewportTransform,i=this.clipPath;this.calcViewportBoundaries(),this.clearContext(t),t.imageSmoothingEnabled=this.imageSmoothingEnabled,t.patternQuality="best",this.fire("before:render",{ctx:t}),this._renderBackground(t),t.save(),t.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._renderObjects(t,e),t.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(t),i&&(i._set("canvas",this),i.shouldCache(),i._transformDone=!0,i.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,i)),this._renderOverlay(t),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(t),this.fire("after:render",{ctx:t}),this.__cleanupTask&&(this.__cleanupTask(),this.__cleanupTask=void 0)}drawClipPathOnCanvas(t,e){const s=this.viewportTransform;t.save(),t.transform(...s),t.globalCompositeOperation="destination-in",e.transform(t),t.scale(1/e.zoomX,1/e.zoomY),t.drawImage(e._cacheCanvas,-e.cacheTranslationX,-e.cacheTranslationY),t.restore()}_renderObjects(t,e){for(let s=0,i=e.length;s!t.excludeFromExport)).map((s=>this._toObject(s,t,e)))},this.__serializeBgOverlay(t,e)),r?{clipPath:r}: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 $t(n)?n.excludeFromExport||(s.background=n.toObject(e)):n&&(s.background=n),$t(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('\n')),this._setSVGBgOverlayColor(s,"background"),this._setSVGBgOverlayImage(s,"backgroundImage",e),this._setSVGObjects(s,e),this.clipPath&&s.push("\n"),this._setSVGBgOverlayColor(s,"overlay"),this._setSVGBgOverlayImage(s,"overlayImage",e),s.push(""),s.join("")}_setSVGPreamble(t,e){e.suppressPreamble||t.push('\n','\n')}_setSVGHeader(t,e){const s=e.width||"".concat(this.width),i=e.height||"".concat(this.height),r=o.NUM_FRACTION_DIGITS,n=e.viewBox;let a;if(n)a='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const t=this.viewportTransform;a='viewBox="'.concat(qt(-t[4]/t[0],r)," ").concat(qt(-t[5]/t[3],r)," ").concat(qt(this.width/t[0],r)," ").concat(qt(this.height/t[3],r),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("\n',"Created with Fabric.js ",x,"\n","\n",this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),"\n")}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(ft()),'\n').concat(e.toClipPathSVG(t.reviver),"\n")):""}createSVGRefElementsMarkup(){return["background","overlay"].map((t=>{const e=this["".concat(t,"Color")];if($t(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?Qt(i):""})}})).join("")}createSVGFontFacesMarkup(){const t=[],e={},s=o.fontPaths;this._objects.forEach((function e(s){t.push(s),ht(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\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($t(s)){const i=s.repeat||"",r=this.width,n=this.height,o=this["".concat(e,"Vpt")]?Qt(wt(this.viewportTransform)):"";t.push('\n'))}else t.push('\n")}loadFromJSON(t,e){let{signal:s}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t)return Promise.reject(new h("`json` is undefined"));const i="string"==typeof t?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:o,overlayImage:a,overlay:c,clipPath:l}=i,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([It(r,{reviver:e,signal:s}),Bt({backgroundImage:n,backgroundColor:o,overlayImage:a,overlayColor:c,clipPath:l},{signal:s})]).then((t=>{let[e,s]=t;return this.clear(),this.add(...e),this.set(i),this.set(s),this.renderOnAddRemove=u,this}))}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=vt(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 yt(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=vt({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}),et.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"#")}}t(ue,"ownDefaults",le);const de=["touchstart","touchmove","touchend"];const ge=t=>{const e=ie(t.target),s=function(t){const e=t.changedTouches;return e&&e[0]?e[0]:t}(t);return new ot(s.clientX+e.left,s.clientY+e.top)},fe=t=>de.includes(t.type)||"touch"===t.pointerType,pe=t=>{t.preventDefault(),t.stopPropagation()},me=t=>{let e=0,s=0,i=0,r=0;for(let n=0,o=t.length;ni||!n)&&(i=o),(or||!n)&&(r=a),(a_e(t,St(e,t.calcOwnMatrix())),_e=(t,e)=>{const s=kt(e),{translateX:r,translateY:n,scaleX:o,scaleY:a}=s,h=i(s,ve),c=new ot(r,n);t.flipX=!1,t.flipY=!1,Object.assign(t,h),t.set({scaleX:o,scaleY:a}),t.setPositionByOrigin(c,D,D)},xe=t=>{t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.flipX=!1,t.flipY=!1,t.rotate(0)},Ce=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}),be=(t,e,s)=>{const i=t/2,r=e/2,n=[new ot(-i,-r),new ot(i,-r),new ot(-i,r),new ot(i,r)].map((t=>t.transform(s))),o=me(n);return new ot(o.width,o.height)},we=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:T;return St(wt(arguments.length>1&&void 0!==arguments[1]?arguments[1]:T),t)},Se=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(we(e,s))},Te=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;return t.transform(we(e,s),!0)},Oe=(t,e,s)=>{const i=we(e,s);return _e(t,St(i,t.calcOwnMatrix())),i},ke=(t,e)=>{var i;const{transform:{target:r}}=e;null===(i=r.canvas)||void 0===i||i.fire("object:".concat(t),s(s({},e),{},{target:r})),r.fire(t,e)},De={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Me=t=>"string"==typeof t?De[t]:t-.5,Pe="not-allowed";function Ee(t){return Me(t.originX)===Me(D)&&Me(t.originY)===Me(D)}function Ae(t){return.5-Me(t)}const je=(t,e)=>t[e],Fe=(t,e,s,i)=>({e:t,transform:e,pointer:new ot(s,i)});function Le(t,e){const s=t.getTotalAngle()+xt(Math.atan2(e.y,e.x))+360;return Math.round(s%360/45)}function Re(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,D,D,s,i):new ot(t.left,t.top);return(t.angle?e.rotate(-_t(t.angle),r):e).subtract(n)}(o,new ot(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 Ie=(t,e,s,i)=>{const{target:r,offsetX:n,offsetY:o}=e,a=s-n,h=i-o,c=!je(r,"lockMovementX")&&r.left!==a,l=!je(r,"lockMovementY")&&r.top!==h;return c&&r.set(M,a),l&&r.set(P,h),(c||l)&&ke(L,Fe(t,e,s,i)),c||l};class Be{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",s=this.strokeWidth?this.strokeWidth:"0",i=this.strokeDashArray?this.strokeDashArray.join(" "):j,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=Zt(K,this.fill);return[Zt(J,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(Qt(s));return"".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(ft()),p='\n').concat(a.toClipPathSVG(s),"\n")),c&&g.push("\n"),g.push("\n");const m=[n,h,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,$t(u)&&g.push(u.toSVG(this)),$t(l)&&g.push(l.toSVG(this)),d&&g.push(d.toSVG(this)),a&&g.push(p),g.push(t.join("")),g.push("\n"),c&&g.push("\n"),s?s(g.join("")):g.join("")}addPaintOrder(){return this.paintFirst!==K?' paint-order="'.concat(this.paintFirst,'" '):""}}function Xe(t){return new RegExp("^("+t.join("|")+")\\b","i")}var Ye;const We=String.raw(Ye||(Ye=r(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Ve="http://www.w3.org/2000/svg",ze=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+We+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+We+"))?\\s+(.*)"),He={cx:M,x:M,r:"radius",cy:P,y:P,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"},Ge="font-size",Ne="clip-path",Ue=Xe(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]),qe=Xe(["symbol","image","marker","pattern","view","svg"]),Ke=Xe(["symbol","g","a","svg","clipPath","defs"]),Je=new RegExp("^\\s*("+We+"+)\\s*,?\\s*("+We+"+)\\s*,?\\s*("+We+"+)\\s*,?\\s*("+We+"+)\\s*$"),Qe=new ot(1,0),Ze=new ot,$e=(t,e)=>t.rotate(e),ts=(t,e)=>new ot(e).subtract(t),es=t=>t.distanceFrom(Ze),ss=(t,e)=>Math.atan2(os(t,e),as(t,e)),is=t=>ss(Qe,t),rs=t=>t.eq(Ze)?t:t.scalarDivide(es(t)),ns=function(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return rs(new ot(-t.y,t.x).scalarMultiply(e?1:-1))},os=(t,e)=>t.x*e.y-t.y*e.x,as=(t,e)=>t.x*e.x+t.y*e.y,hs=(t,e,s)=>{if(t.eq(e)||t.eq(s))return!0;const i=os(e,s),r=os(e,t),n=os(s,t);return i>=0?r>=0&&n<=0:!(r<=0&&n>=0)},cs="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",ls=new RegExp("(?:\\s|^)"+cs+cs+"("+We+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class us{constructor(t){const e="string"==typeof t?us.parseShadow(t):t;Object.assign(this,us.ownDefaults,e),this.id=ft()}static parseShadow(t){const e=t.trim(),[,s=0,i=0,r=0]=(ls.exec(e)||[]).map((t=>parseFloat(t)||0));return{color:(e.replace(ls,"")||"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=$e(new ot(this.offsetX,this.offsetY),_t(-t.angle)),s=new Ut(this.color);let i=40,r=40;return t.width&&t.height&&(i=100*qt((Math.abs(e.x)+this.blur)/t.width,o.NUM_FRACTION_DIGITS)+20,r=100*qt((Math.abs(e.y)+this.blur)/t.height,o.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'\n\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\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=us.ownDefaults;return this.includeDefaultValues?t:Yt(t,((t,s)=>t!==e[s]))}static async fromObject(t){return new this(t)}}t(us,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),t(us,"type","shadow"),tt.setClass(us,"shadow");const ds=(t,e,s)=>Math.max(t,Math.min(e,s)),gs=[P,M,G,N,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",U,q],fs=[K,J,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],ps={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:M,originY:P,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:K,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},ms=(t,e,s,i)=>(tt*Math.pow(2,10*(i-=1))*Math.sin((i*r-e)*w/s),ys=(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,_s=(t,e,s,i)=>(t/=i)<1/2.75?s*(7.5625*t*t)+e:t<2/2.75?s*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?s*(7.5625*(t-=2.25/2.75)*t+.9375)+e:s*(7.5625*(t-=2.625/2.75)*t+.984375)+e,xs=(t,e,s,i)=>s-_s(i-t,0,s,i)+e;var Cs=Object.freeze({__proto__:null,defaultEasing:ys,easeInBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*(t/=i)*t*((r+1)*t-r)+e},easeInBounce:xs,easeInCirc:(t,e,s,i)=>-s*(Math.sqrt(1-(t/=i)*t)-1)+e,easeInCubic:(t,e,s,i)=>s*(t/i)**3+e,easeInElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h}=ms(r,s,n,1.70158);return-vs(o,a,h,t,i)+e},easeInExpo:(t,e,s,i)=>0===t?e:s*2**(10*(t/i-1))+e,easeInOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return(t/=i/2)<1?s/2*(t*t*((1+(r*=1.525))*t-r))+e:s/2*((t-=2)*t*((1+(r*=1.525))*t+r)+2)+e},easeInOutBounce:(t,e,s,i)=>t(t/=i/2)<1?-s/2*(Math.sqrt(1-t**2)-1)+e:s/2*(Math.sqrt(1-(t-=2)*t)+1)+e,easeInOutCubic:(t,e,s,i)=>(t/=i/2)<1?s/2*t**3+e:s/2*((t-2)**3+2)+e,easeInOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(2===(t/=i/2))return e+s;n||(n=i*(.3*1.5));const{a:o,s:a,p:h,c:c}=ms(r,s,n,1.70158);return t<1?-.5*vs(o,a,h,t,i)+e:o*Math.pow(2,-10*(t-=1))*Math.sin((t*i-a)*w/h)*.5+c+e},easeInOutExpo:(t,e,s,i)=>0===t?e:t===i?e+s:(t/=i/2)<1?s/2*2**(10*(t-1))+e:s/2*-(2**(-10*--t)+2)+e,easeInOutQuad:(t,e,s,i)=>(t/=i/2)<1?s/2*t**2+e:-s/2*(--t*(t-2)-1)+e,easeInOutQuart:(t,e,s,i)=>(t/=i/2)<1?s/2*t**4+e:-s/2*((t-=2)*t**3-2)+e,easeInOutQuint:(t,e,s,i)=>(t/=i/2)<1?s/2*t**5+e:s/2*((t-2)**5+2)+e,easeInOutSine:(t,e,s,i)=>-s/2*(Math.cos(Math.PI*t/i)-1)+e,easeInQuad:(t,e,s,i)=>s*(t/=i)*t+e,easeInQuart:(t,e,s,i)=>s*(t/=i)*t**3+e,easeInQuint:(t,e,s,i)=>s*(t/i)**5+e,easeInSine:(t,e,s,i)=>-s*Math.cos(t/i*b)+s+e,easeOutBack:function(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1.70158;return s*((t=t/i-1)*t*((r+1)*t+r)+1)+e},easeOutBounce:_s,easeOutCirc:(t,e,s,i)=>s*Math.sqrt(1-(t=t/i-1)*t)+e,easeOutCubic:(t,e,s,i)=>s*((t/i-1)**3+1)+e,easeOutElastic:(t,e,s,i)=>{const r=s;let n=0;if(0===t)return e;if(1===(t/=i))return e+s;n||(n=.3*i);const{a:o,s:a,p:h,c:c}=ms(r,s,n,1.70158);return o*2**(-10*t)*Math.sin((t*i-a)*w/h)+c+e},easeOutExpo:(t,e,s,i)=>t===i?e+s:s*-(2**(-10*t/i)+1)+e,easeOutQuad:(t,e,s,i)=>-s*(t/=i)*(t-2)+e,easeOutQuart:(t,e,s,i)=>-s*((t=t/i-1)*t**3-1)+e,easeOutQuint:(t,e,s,i)=>s*((t/i-1)**5+1)+e,easeOutSine:(t,e,s,i)=>s*Math.sin(t/i*b)+e});const bs=()=>!1;class ws{constructor(e){let{startValue:s,byValue:i,duration:r=500,delay:n=0,easing:o=ys,onStart:a=C,onChange:h=C,onComplete:c=C,abort:l=bs,target:u}=e;t(this,"_state","pending"),t(this,"durationProgress",0),t(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=n,this.easing=o,this._onStart=a,this._onChange=h,this._onComplete=c,this._abort=l,this.target=u,this.startValue=s,this.byValue=i,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((()=>ut(t)),this.delay):ut(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),ut(this.tick)))}register(){et.push(this)}unregister(){et.remove(this)}abort(){this._state="aborted",this.unregister()}}const Ss=["startValue","endValue"];class Ts extends ws{constructor(t){let{startValue:e=0,endValue:r=100}=t;super(s(s({},i(t,Ss)),{},{startValue:e,byValue:r-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 Os=["startValue","endValue"];class ks extends ws{constructor(t){let{startValue:e=[0],endValue:r=[100]}=t;super(s(s({},i(t,Os)),{},{startValue:e,byValue:r.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 Ds=["startValue","endValue","easing","onChange","onComplete","abort"],Ms=(t,e,s,i)=>e+s*(1-Math.cos(t/i*b)),Ps=t=>t&&((e,s,i)=>t(new Ut(e).toRgba(),s,i));class Es extends ws{constructor(t){let{startValue:e,endValue:r,easing:n=Ms,onChange:o,onComplete:a,abort:h}=t,c=i(t,Ds);const l=new Ut(e).getSource(),u=new Ut(r).getSource();super(s(s({},c),{},{startValue:l,byValue:u.map(((t,e)=>t-l[e])),easing:n,onChange:Ps(o),onComplete:Ps(a),abort:Ps(h)}))}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),ds(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 As(t){const e=(t=>Array.isArray(t.startValue)||Array.isArray(t.endValue))(t)?new ks(t):new Ts(t);return e.start(),e}function js(t){const e=new Es(t);return e.start(),e}class Fs{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!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=ts(e,s),n=ts(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 ot(t).setX(Math.min(t.x-1,...e.map((t=>t.x))));let i=0;for(let r=0;r4&&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 Fs("Intersection").append(new ot(t.x+e*o,t.y+e*a)):new Fs}if(0===d||0===g){const o=r||n||Fs.isPointContained(t,s,i)||Fs.isPointContained(e,s,i)||Fs.isPointContained(s,t,e)||Fs.isPointContained(i,t,e);return new Fs(o?"Coincident":void 0)}return new Fs("Parallel")}static intersectSegmentLine(t,e,s,i){return Fs.intersectLineLine(t,e,s,i,!1,!0)}static intersectSegmentSegment(t,e,s,i){return Fs.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 Fs,n=s.length;for(let o,a,h,c=0;c0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,s){return Fs.intersectLinePolygon(t,e,s,!1)}static intersectPolygonPolygon(t,e){const s=new Fs,i=t.length,r=[];for(let n=0;n0&&r.length===t.length?new Fs("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 ot(r.x,i.y),o=new ot(i.x,r.y);return Fs.intersectPolygonPolygon(t,[i,n,r,o])}}class Ls extends lt{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?bt(t,this.group.calcTransformMatrix()):t}setXY(t,e,s){this.group&&(t=bt(t,wt(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,s)}getRelativeXY(){return new ot(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=>bt(e,t)))}return r}intersectsWithRect(t,e){return"Intersection"===Fs.intersectPolygonRectangle(this.getCoords(),t,e).status}intersectsWithObject(t){const e=Fs.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}=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 Fs.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;if(this.intersectsWithRect(t,e))return!0;return 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 me(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(G,t),this._set(N,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?xt(Ot(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return(null===(t=this.canvas)||void 0===t?void 0:t.viewportTransform)||T.concat()}calcACoords(){const t=Mt({angle:this.angle}),{x:e,y:s}=this.getRelativeCenterPoint(),i=Dt(e,s),r=St(i,t),n=this._getTransformedDimensions(),o=n.x/2,a=n.y/2;return{tl:bt({x:-o,y:-a},r),tr:bt({x:o,y:-a},r),bl:bt({x:-o,y:a},r),br:bt({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,Me(this.originX),Me(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=St(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=Lt(i);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new ot(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=s({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let r=i,n=0;this.strokeUniform&&(r=0,n=i);const o=e.width+r,a=e.height+r;let h;return h=0===e.skewX&&0===e.skewY?new ot(o*e.scaleX,a*e.scaleY):be(o,a,Ft(e)),h.scalarAdd(n)}translateToGivenOrigin(t,e,s,i,r){let n=t.x,o=t.y;const a=Me(i)-Me(e),h=Me(r)-Me(s);if(a||h){const t=this._getTransformedDimensions();n+=a*t.x,o+=h*t.y}return new ot(n,o)}translateToCenterPoint(t,e,s){if(e===D&&s===D)return t;const i=this.translateToGivenOrigin(t,e,s,D,D);return this.angle?i.rotate(_t(this.angle),t):i}translateToOriginPoint(t,e,s){const i=this.translateToGivenOrigin(t,D,D,e,s);return this.angle?i.rotate(_t(this.angle),t):i}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?bt(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new ot(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(),M,P)}}const Rs=["type"],Is=["extraParam"];let Bs=class e extends Ls{static getDefaults(){return e.ownDefaults}get type(){const t=this.constructor.type;return"FabricObject"===t?"object":t.toLowerCase()}set type(t){a("warn","Setting type has no effect",t)}constructor(s){super(),t(this,"_cacheContext",null),Object.assign(this,e.ownDefaults),this.setOptions(s)}_createCacheCanvas(){this._cacheCanvas=pt(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,s=t.height,i=o.maxCacheSideLimit,r=o.minCacheSideLimit;if(e<=i&&s<=i&&e*s<=o.perfLimitSizeTotal)return ec&&(t.zoomX/=e/c,t.width=c,t.capped=!0),s>l&&(t.zoomY/=s/l,t.height=l,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;if(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 ot(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=kt(this.calcTransformMatrix());return new ot(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){t.transform(i)})),e.parentClipPaths.push(t),t.absolutePositioned){const t=wt(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()),!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,$t(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&&($t(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)||T,a=r*i,h=n*i,c=e.nonScaling?new ot(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*o.browserShadowBlurConstant*(a+h)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*h*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!$t(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===J?(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=vt({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 ot(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(tt.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Ce(this),s=this.group,i=this.shadow,r=Math.abs,n=t.enableRetinaScaling?y():1,o=(t.multiplier||1)*n,a=t.canvasProvider||(t=>new ue(t,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&xe(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Oe(this,this.getViewportTransform()),this.setCoords();const h=pt(),c=this.getBoundingRect(),l=this.shadow,u=new ot;if(l){const t=l.blur,e=l.nonScaling?new ot(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 ot(f.width/2,f.height/2),D,D);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 yt(this.toCanvasElement(t),t.format||"png",t.quality||1)}isType(){for(var t=arguments.length,e=new Array(t),s=0;s{let[i,r]=s;return t[i]=this._animate(i,r,e),t}),{})}_animate(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=t.split("."),n=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:h,onComplete:c}=i,l=s(s({},i),{},{target:this,startValue:null!=a?a:r.reduce(((t,e)=>t[e]),this),endValue:e,abort:null==o?void 0:o.bind(this),onChange:(t,e,s)=>{r.reduce(((e,s,i)=>(i===r.length-1&&(e[s]=t),e[s])),this),h&&h(t,e,s)},onComplete:(t,e,s)=>{this.setCoords(),c&&c(t,e,s)}});return n?js(l):As(l)}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-1&&n>o}toObject(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).concat(e.customProperties,this.constructor.customProperties||[]);let i;const r=o.NUM_FRACTION_DIGITS,{clipPath:n,fill:a,stroke:h,shadow:c,strokeDashArray:l,left:u,top:d,originX:g,originY:f,width:p,height:m,strokeWidth:v,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:w,scaleX:S,scaleY:T,angle:O,flipX:k,flipY:D,opacity:M,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:L,skewY:R}=this;n&&!n.excludeFromExport&&(i=n.toObject(t.concat("inverted","absolutePositioned")));const I=t=>qt(t,r),B=s(s({},Xt(this,t)),{},{type:this.constructor.type,version:x,originX:g,originY:f,left:I(u),top:I(d),width:I(p),height:I(m),fill:te(a)?a.toObject():a,stroke:te(h)?h.toObject():h,strokeWidth:I(v),strokeDashArray:l?l.concat():l,strokeLineCap:y,strokeDashOffset:_,strokeLineJoin:C,strokeUniform:b,strokeMiterLimit:I(w),scaleX:I(S),scaleY:I(T),angle:I(O),flipX:k,flipY:D,opacity:I(M),shadow:c?c.toObject():c,visible:P,backgroundColor:E,fillRule:A,paintFirst:j,globalCompositeOperation:F,skewX:I(L),skewY:I(R)},i?{clipPath:i}:null);return this.includeDefaultValues?B:this._removeDefaultValues(B)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),s=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return Yt(t,((t,e)=>{if(e===M||e===P||"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=i(t,Rs),s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{extraParam:r}=s,n=i(s,Is);return Bt(e,n).then((t=>r?(delete t[r],new this(e[r],t)):new this(t)))}static fromObject(t,e){return this._fromObject(t,e)}};t(Bs,"stateProperties",gs),t(Bs,"cacheProperties",fs),t(Bs,"ownDefaults",ps),t(Bs,"type","FabricObject"),t(Bs,"colorProperties",[K,J,"backgroundColor"]),t(Bs,"customProperties",[]),tt.setClass(Bs),tt.setClass(Bs,"object");const Xs=(t,e,i)=>(r,n,o,a)=>{const h=e(r,n,o,a);return h&&ke(t,s(s({},Fe(r,n,o,a)),i)),h};function Ys(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 Ws=Xs(Y,Ys(((t,e,s,i)=>{const r=Re(e,e.originX,e.originY,s,i);if(Me(e.originX)===Me(D)||Me(e.originX)===Me(A)&&r.x<0||Me(e.originX)===Me(M)&&r.x>0){const{target:t}=e,s=t.strokeWidth/(t.strokeUniform?t.scaleX:1),i=Ee(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 Vs(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?J:K,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,w,!1),t[h](),c&&t.stroke(),t.restore()}function zs(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?J:K,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(_t(d)),t["".concat(h,"Rect")](-l,-u,n,o),c&&t.strokeRect(-l,-u,n,o),t.restore()}class Hs{constructor(e){t(this,"visible",!0),t(this,"actionName",H),t(this,"angle",0),t(this,"x",0),t(this,"y",0),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"sizeX",0),t(this,"sizeY",0),t(this,"touchSizeX",0),t(this,"touchSizeY",0),t(this,"cursorStyle","crosshair"),t(this,"withConnection",!1),Object.assign(this,e)}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)&&Fs.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}positionHandler(t,e,s,i){return new ot(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,s,i,r,n){const o=Tt([Dt(s,i),Mt({angle:t}),Pt((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new ot(-.5,-.5).transform(o),tr:new ot(.5,-.5).transform(o),br:new ot(.5,.5).transform(o),bl:new ot(-.5,.5).transform(o)}}render(t,e,s,i,r){if("circle"===((i=i||{}).cornerStyle||r.cornerStyle))Vs.call(this,t,e,s,i,r);else zs.call(this,t,e,s,i,r)}}const Gs=(t,e,s)=>s.lockRotation?Pe:e.cursorStyle,Ns=Xs(I,Ys(((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(je(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=xt(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){const i=Us(t,s);if(qs(s,0!==e.x&&0===e.y?"x":0===e.x&&0!==e.y?"y":"",i))return Pe;const r=Le(s,e);return"".concat(Ks[r],"-resize")};function Qs(t,e,s,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};const n=e.target,o=r.by,a=Us(t,n);let h,c,l,u,d,g;if(qs(n,o,a))return!1;if(e.gestureScale)c=e.scaleX*e.gestureScale,l=e.scaleY*e.gestureScale;else{if(h=Re(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),je(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);Ee(e)&&(c*=2,l*=2),e.signX!==d&&"y"!==o&&(e.originX=Ae(e.originX),c*=-1,e.signX=d),e.signY!==g&&"x"!==o&&(e.originY=Ae(e.originY),l*=-1,e.signY=g)}const f=n.scaleX,p=n.scaleY;return o?("x"===o&&n.set(G,c),"y"===o&&n.set(N,l)):(!je(n,"lockScalingX")&&n.set(G,c),!je(n,"lockScalingY")&&n.set(N,l)),f!==n.scaleX||p!==n.scaleY}const Zs=Xs(R,Ys(((t,e,s,i)=>Qs(t,e,s,i)))),$s=Xs(R,Ys(((t,e,s,i)=>Qs(t,e,s,i,{by:"x"})))),ti=Xs(R,Ys(((t,e,s,i)=>Qs(t,e,s,i,{by:"y"})))),ei=["target","ex","ey","skewingSide"],si={x:{counterAxis:"y",scale:G,skew:U,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:N,skew:q,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},ii=["ns","nesw","ew","nwse"],ri=(t,e,s)=>{if(0!==e.x&&je(s,"lockSkewingY"))return Pe;if(0!==e.y&&je(s,"lockSkewingX"))return Pe;const i=Le(s,e)%4;return"".concat(ii[i],"-resize")};function ni(t,e,r,n,o){const{target:a}=r,{counterAxis:h,origin:c,lockSkewing:l,skew:u,flip:d}=si[t];if(je(a,l))return!1;const{origin:g,flip:f}=si[h],p=Me(r[g])*(a[f]?-1:1),m=-Math.sign(p)*(a[d]?-1:1),v=.5*-((0===a[u]&&Re(r,D,D,n,o)[t]>0||a[u]>0?1:-1)*m)+.5,y=Xs(X,Ys(((e,s,r,n)=>function(t,e,s){let{target:r,ex:n,ey:o,skewingSide:a}=e,h=i(e,ei);const{skew:c}=si[t],l=s.subtract(new ot(n,o)).divide(new ot(r.scaleX,r.scaleY))[t],u=r[c],d=h[c],g=Math.tan(_t(d)),f="y"===t?r._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:r._getTransformedDimensions({scaleX:1,scaleY:1}).y,p=2*l*a/Math.max(f,1)+g,m=xt(Math.atan(p));r.set(c,m);const v=u!==r[c];if(v&&"y"===t){const{skewX:t,scaleX:e}=r,s=r._getTransformedDimensions({skewY:u}),i=r._getTransformedDimensions(),n=0!==t?s.x/i.x:1;1!==n&&r.set(G,n*e)}return v}(t,s,new ot(r,n)))));return y(e,s(s({},r),{},{[c]:v,skewingSide:m}),n,o)}const oi=(t,e,s,i)=>ni("x",t,e,s,i),ai=(t,e,s,i)=>ni("y",t,e,s,i);function hi(t,e){return t[e.canvas.altActionKey]}const ci=(t,e,s)=>{const i=hi(t,s);return 0===e.x?i?U:N:0===e.y?i?q:G:""},li=(t,e,s)=>hi(t,s)?ri(0,e,s):Js(t,e,s),ui=(t,e,s,i)=>hi(t,e.target)?ai(t,e,s,i):$s(t,e,s,i),di=(t,e,s,i)=>hi(t,e.target)?oi(t,e,s,i):ti(t,e,s,i),gi=()=>({ml:new Hs({x:-.5,y:0,cursorStyleHandler:li,actionHandler:ui,getActionName:ci}),mr:new Hs({x:.5,y:0,cursorStyleHandler:li,actionHandler:ui,getActionName:ci}),mb:new Hs({x:0,y:.5,cursorStyleHandler:li,actionHandler:di,getActionName:ci}),mt:new Hs({x:0,y:-.5,cursorStyleHandler:li,actionHandler:di,getActionName:ci}),tl:new Hs({x:-.5,y:-.5,cursorStyleHandler:Js,actionHandler:Zs}),tr:new Hs({x:.5,y:-.5,cursorStyleHandler:Js,actionHandler:Zs}),bl:new Hs({x:-.5,y:.5,cursorStyleHandler:Js,actionHandler:Zs}),br:new Hs({x:.5,y:.5,cursorStyleHandler:Js,actionHandler:Zs}),mtr:new Hs({x:0,y:-.5,actionHandler:Ns,cursorStyleHandler:Gs,offsetY:-40,withConnection:!0,actionName:B})}),fi=()=>({mr:new Hs({x:.5,y:0,actionHandler:Ws,cursorStyleHandler:li,actionName:Y}),ml:new Hs({x:-.5,y:0,actionHandler:Ws,cursorStyleHandler:li,actionName:Y})}),pi=()=>s(s({},gi()),fi());class mi extends Bs{static getDefaults(){return s(s({},super.getDefaults()),mi.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),mi.ownDefaults),this.setOptions(t)}static createControls(){return{controls:gi()}}_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(H))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=Dt(e.x,e.y),i=Mt({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=St(s,i),n=St(t,r),o=St(n,[1/t[0],0,0,1/t[3],0,0]),a=this.group?kt(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)}drawSelectionBackground(t){if(!this.selectionBackgroundColor||this.canvas&&this.canvas._activeObject!==this)return;t.save();const e=this.getRelativeCenterPoint(),s=this._calculateCurrentDimensions(),i=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/i[0],1/i[3]),t.rotate(_t(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 i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=s({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{hasBorders:i,hasControls:r}=this,n=s({hasBorders:i,hasControls:r},e),o=this.getViewportTransform(),a=n.hasBorders,h=n.hasControls,c=St(o,this.calcTransformMatrix()),l=kt(c);t.save(),t.translate(l.translateX,l.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(l.angle-=180),t.rotate(_t(this.group?l.angle:this.angle)),a&&this.drawBorders(t,l,e),h&&this.drawControls(t,e),t.restore()}drawBorders(t,e,s){let i;if(s&&s.forActiveSelection||this.group){const t=be(this.width,this.height,Ft(e)),s=this.isStrokeAccountedForInDimensions()?at:(this.strokeUniform?(new ot).scalarAdd(this.canvas?this.canvas.getZoom():1):new ot(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 i=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:n,cornerColor:o}=this,a=s({cornerStrokeColor:r,cornerDashArray:n,cornerColor:o},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl(((e,s)=>{if(e.getVisibility(this,s)){const i=this.oCoords[s];e.render(t,i.x,i.y,a,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 vi(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}t(mi,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class yi extends mi{}vi(yi,[Be]),tt.setClass(yi),tt.setClass(yi,"object");const _i=(t,e,s,i)=>{const r=2*(i=Math.round(i))+1,{data:n}=t.getImageData(e-i,s-i,r,r);for(let t=3;t0)return!1}return!0};class xi{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new ot(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new ot(1/this.options.scaleX,1/this.options.scaleY):new ot(1,1)}createSideVector(t,e){const s=ts(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 ot(t);return e.y+=e.x*Math.tan(_t(this.options.skewY)),e.x+=e.y*Math.tan(_t(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Ci=new ot;class bi extends xi{static getOrthogonalRotationFactor(t,e){const s=e?ss(t,e):is(t);return Math.abs(s)2&&void 0!==arguments[2]?arguments[2]:this.strokeProjectionMagnitude;const i=this.createSideVector(t,e),r=ns(i),n=bi.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,s*n)}projectBevel(){const t=[];return(this.alpha%w==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?es(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return es(i)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(i))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const s=[],i=new ot(bi.getOrthogonalRotationFactor(this.bisector),bi.getOrthogonalRotationFactor(new ot(this.bisector.y,this.bisector.x)));return[new ot(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i),new ot(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(i)].forEach((i=>{hs(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 ot(Math.tan(_t(i)),Math.tan(_t(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 ot(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 ot(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=>{hs(i,t,e)&&s.push(this.applySkew(this.A).add(i))})),s}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%w==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=os(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 wi extends xi{constructor(t,e,s){super(s),this.A=new ot(t),this.T=new ot(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(ns(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 ot(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 bi(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new ot(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(rs(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 Si=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 ot(e)),t)),[new ot(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],s,t))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 wi(t,t,e).project()):!s||0!==r&&r!==n.length-1?i.push(...new bi(t,o,a,e).project()):i.push(...new wi(t,0===r?a:o,e).project())})),i},Ti=t=>{const e={};return Object.keys(t).forEach((i=>{e[i]={},Object.keys(t[i]).forEach((r=>{e[i][r]=s({},t[i][r])}))})),e},Oi=t=>t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">"),ki=t=>{const e=[];for(let s,i=0;i{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};var Mi=Object.freeze({__proto__:null,capitalize:function(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return"".concat(t.charAt(0).toUpperCase()).concat(e?t.slice(1):t.slice(1).toLowerCase())},escapeXml:Oi,graphemeSplit:ki});const Pi=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.textBackgroundColor!==e.textBackgroundColor||t.deltaY!==e.deltaY||s&&(t.overline!==e.overline||t.underline!==e.underline||t.linethrough!==e.linethrough)},Ei=(t,e)=>{const s=e.split("\n"),i=[];let r=-1,n={};t=Ti(t);for(let e=0;e0&&(Pi(n,o,!0)?i.push({start:r,end:r+1,style:o}):i[i.length-1].end++),n=o||{}}else r+=o.length,n={}}return i},Ai=(t,e)=>{if(!Array.isArray(t))return Ti(t);const i=e.split(F),r={};let n=-1,o=0;for(let e=0;e{var e;return null!==(e=He[t])&&void 0!==e?e:t},Ii=new RegExp("(".concat(We,")"),"gi"),Bi=t=>t.replace(Ii," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var Xi,Yi,Wi,Vi,zi,Hi,Gi;const Ni="(".concat(We,")"),Ui=String.raw(Xi||(Xi=r(["(skewX)(",")"],["(skewX)\\(","\\)"])),Ni),qi=String.raw(Yi||(Yi=r(["(skewY)(",")"],["(skewY)\\(","\\)"])),Ni),Ki=String.raw(Wi||(Wi=r(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Ni,Ni,Ni),Ji=String.raw(Vi||(Vi=r(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Ni,Ni),Qi=String.raw(zi||(zi=r(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Ni,Ni),Zi=String.raw(Hi||(Hi=r(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Ni,Ni,Ni,Ni,Ni,Ni),$i="(?:".concat(Zi,"|").concat(Qi,"|").concat(Ki,"|").concat(Ji,"|").concat(Ui,"|").concat(qi,")"),tr="(?:".concat($i,"*)"),er=String.raw(Gi||(Gi=r(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),tr),sr=new RegExp(er),ir=new RegExp($i),rr=new RegExp($i,"g");function nr(t){const e=[];if(!(t=Bi(t).replace(/\s*([()])\s*/gi,"$1"))||t&&!sr.test(t))return[...T];for(const s of t.matchAll(rr)){const t=ir.exec(s[0]);if(!t)continue;let i=T;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=Dt(a,h);break;case B:i=Mt({angle:a},{x:h,y:c});break;case H:i=Pt(a,h);break;case U:i=At(a);break;case q:i=jt(a);break;case"matrix":i=[a,h,c,l,u,d]}e.push(i)}return Tt(e)}function or(t,e,s,i){const r=Array.isArray(e);let n,o=e;if(t!==K&&t!==J||e!==j){if("strokeUniform"===t)return"non-scaling-stroke"===e;if("strokeDashArray"===t)o=e===j?null:e.replace(/,/g," ").split(/\s+/).map(parseFloat);else if("transformMatrix"===t)o=s&&s.transformMatrix?St(s.transformMatrix,nr(e)):nr(e);else if("visible"===t)o=e!==j&&"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?M:"end"===e?A:D;else if("charSpacing"===t)n=Kt(e,i)/i*1e3;else if("paintFirst"===t){const t=e.indexOf(K),s=e.indexOf(J);o=K,(t>-1&&s>-1&&s-1)&&(o=J)}else{if("href"===t||"xlink:href"===t||"font"===t||"id"===t)return e;if("imageSmoothing"===t)return"optimizeQuality"===e;n=r?e.map(Kt):Kt(e,i)}}else o="";return!r&&isNaN(n)?o:n}function ar(t,e){const s=t.match(ze);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=Kt(n)),a&&(e.fontFamily=a),o&&(e.lineHeight="normal"===o?1:o)}function hr(t,e){t.replace(/;\s*$/,"").split(";").forEach((t=>{if(!t)return;const[s,i]=t.split(":");e[s.trim().toLowerCase()]=i.trim()}))}function cr(t){const e={},s=t.getAttribute("style");return s?("string"==typeof s?hr(s,e):function(t,e){Object.entries(t).forEach((t=>{let[s,i]=t;void 0!==i&&(e[s.toLowerCase()]=i)}))}(s,e),e):e}const lr={stroke:"strokeOpacity",fill:"fillOpacity"};function ur(t,e,i){if(!t)return{};let r,n={},o=O;t.parentNode&&Ke.test(t.parentNode.nodeName)&&(n=ur(t.parentElement,e,i),n.fontSize&&(r=o=Kt(n.fontSize)));const a=s(s(s({},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]:{},i={};for(const r in e)Li(t,r.split(" "))&&(i=s(s({},i),e[r]));return i}(t,i)),cr(t));a[Ne]&&t.setAttribute(Ne,a[Ne]),a[Ge]&&(r=Kt(a[Ge],o),a[Ge]="".concat(r));const h={};for(const t in a){const e=Ri(t),s=or(e,a[t],n,r);h[e]=s}h&&h.font&&ar(h.font,h);const c=s(s({},n),h);return Ke.test(t.nodeName)?c:function(t){const e=yi.getDefaults();return Object.entries(lr).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 Ut(t[i]);t[i]=n.setAlpha(qt(n.getAlpha()*t[r],2)).toRgba()})),t}(c)}const dr=["left","top","width","height","visible"],gr=["rx","ry"];class fr extends yi{static getDefaults(){return s(s({},super.getDefaults()),fr.ownDefaults)}constructor(t){super(),Object.assign(this,fr.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-k*n,r,i+e,r+k*o,i+e,r+o),t.lineTo(i+e,r+s-o),a&&t.bezierCurveTo(i+e,r+s-k*o,i+e-k*n,r+s,i+e-n,r+s),t.lineTo(i+n,r+s),a&&t.bezierCurveTo(i+k*n,r+s,i,r+s-k*o,i,r+s-o),t.lineTo(i,r+o),a&&t.bezierCurveTo(i,r+k*o,i+k*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([...gr,...t])}_toSVG(){const{width:t,height:e,rx:s,ry:i}=this;return["\n')]}static async fromElement(t,e,r){const n=ur(t,this.ATTRIBUTE_NAMES,r),{left:o=0,top:a=0,width:h=0,height:c=0,visible:l=!0}=n,u=i(n,dr);return new this(s(s(s({},e),u),{},{left:o,top:a,width:h,height:c,visible:Boolean(l&&h&&c)}))}}t(fr,"type","Rect"),t(fr,"cacheProperties",[...fs,...gr]),t(fr,"ownDefaults",{rx:0,ry:0}),t(fr,"ATTRIBUTE_NAMES",[...ji,"x","y","rx","ry","width","height"]),tt.setClass(fr),tt.setSVGClass(fr);const pr="initialization",mr="added",vr="removed",yr="imperative",_r=(t,e)=>{const{strokeUniform:s,strokeWidth:i,width:r,height:n,group:o}=e,a=o&&o!==t?we(o.calcTransformMatrix(),t.calcTransformMatrix()):null,h=a?e.getRelativeCenterPoint().transform(a):e.getRelativeCenterPoint(),c=!e.isStrokeAccountedForInDimensions(),l=s&&c?Te(new ot(i,i),void 0,t.calcTransformMatrix()):at,u=!s&&c?i:0,d=be(r+u,n+u,Tt([a,e.calcOwnMatrix()],!0)).add(l).scalarDivide(2);return[h.subtract(d),h.add(d)]};class xr{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:s,strategy:i}=t;return e===pr||e===yr||!!s&&i!==s}shouldLayoutClipPath(t){let{type:e,target:{clipPath:s}}=t;return e!==pr&&s&&!s.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:s,target:i}=e;if(s===yr&&e.overrides)return e.overrides;if(0===t.length)return;const{left:r,top:n,width:o,height:a}=me(t.map((t=>_r(i,t))).reduce(((t,e)=>t.concat(e)),[])),h=new ot(o,a),c=new ot(r,n).add(h.scalarDivide(2));if(s===pr){const t=this.getInitialSize(e,{size:h,center:c});return{center:c,relativeCorrection:new ot(0,0),size:t}}return{center:c.transform(i.calcOwnMatrix()),size:h}}}t(xr,"type","strategy");class Cr extends xr{shouldPerformLayout(t){return!0}}t(Cr,"type","fit-content"),tt.setClass(Cr);const br=["strategy"],wr=["target","strategy","bubbles","prevStrategy"],Sr="layoutManager";class Tr{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Cr;t(this,"strategy",void 0),this.strategy=e,this._subscriptions=new Map}performLayout(t){const e=s(s({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const i=this.getLayoutResult(e);i&&this.commitLayout(e,i),this.onAfterLayout(e,i),this._prevLayoutStrategy=e.strategy}attachHandlers(t,e){const{target:s}=e;return[Q,L,Y,I,R,X,z,W,V].map((e=>t.on(e,(t=>this.performLayout(e===Q?{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:r}=t,{canvas:n}=e;if(r===pr||r===mr?this.subscribeTargets(t):r===vr&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),n&&n.fire("object:layout:before",{target:e,context:t}),r===yr&&t.deep){const r=i(t,br);e.forEachObject((t=>t.layoutManager&&t.layoutManager.performLayout(s(s({},r),{},{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===pr?new ot:e.getRelativeCenterPoint(),{center:o,correction:a=new ot,relativeCorrection:h=new ot}=r,c=n.subtract(o).add(a).transform(i===pr?T:wt(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===pr)?s.set({left:null!==(n=t.x)&&void 0!==n?n:r.x+i.x*Me(s.originX),top:null!==(o=t.y)&&void 0!==o?o:r.y+i.y*Me(s.originY)}):(s.setPositionByOrigin(r,D,D),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:r,strategy:n,bubbles:o,prevStrategy:a}=t,h=i(t,wr),{canvas:c}=r;r.fire("layout:after",{context:t,result:e}),c&&c.fire("object:layout:after",{context:t,result:e,target:r});const l=r.parent;o&&null!=l&&l.layoutManager&&((h.path||(h.path=[])).push(r),l.layoutManager.performLayout(s(s({},h),{},{target:l}))),r.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach((t=>t.forEach((t=>t())))),t.clear()}toObject(){return{type:Sr,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}tt.setClass(Tr,Sr);const Or=["type","objects","layoutManager"];class kr extends Tr{performLayout(){}}class Dr extends(ct(yi)){static getDefaults(){return s(s({},super.getDefaults()),Dr.ownDefaults)}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"_activeObjects",[]),t(this,"__objectSelectionTracker",void 0),t(this,"__objectSelectionDisposer",void 0),Object.assign(this,Dr.ownDefaults),this.setOptions(s),this.groupInit(e,s)}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 Tr,this.layoutManager.performLayout({type:pr,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(a("error","Group: circular object trees are not supported, this call has no effect"),!1):-1===this._objects.indexOf(t)||(a("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;s1?e-1:0),i=1;i{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&&_e(t,St(wt(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||(_e(t,St(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=yi.prototype.shouldCache.call(this);if(t)for(let t=0;tt.setCoords()))}triggerLayout(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.layoutManager.performLayout(s({target:this,type:yr},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 s(s(s({},super.toObject(["subTargetCheck","interactive",...t])),"fit-content"!==e.strategy||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#")}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=fr.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=["\n"],s=this._createSVGBgRect(t);s&&e.push("\t\t",s);for(let s=0;s\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 s=0;s{let[e,i]=t;const r=new this(e,s(s(s({},a),i),{},{layoutManager:new kr}));if(o){const t=tt.getClass(o.type),e=tt.getClass(o.strategy);r.layoutManager=new t(new e)}else r.layoutManager=new Tr;return r.layoutManager.subscribeTargets({type:pr,target:r,targets:r.getObjects()}),r.setCoords(),r}))}}t(Dr,"type","Group"),t(Dr,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),tt.setClass(Dr);const Mr=(t,e)=>Math.min(e.width/t.width,e.height/t.height),Pr=(t,e)=>Math.max(e.width/t.width,e.height/t.height),Er="\\s*,?\\s*",Ar="".concat(Er,"(").concat(We,")"),jr="".concat(Ar).concat(Ar).concat(Ar).concat(Er,"([01])").concat(Er,"([01])").concat(Ar).concat(Ar),Fr={m:"l",M:"L"},Lr=(t,e,s,i,r,n,o,a,h,c,l)=>{const u=rt(t),d=nt(t),g=rt(e),f=nt(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]},Rr=(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 Ir(t,e,s,i,r,n,a,h){let c;if(o.cachesBoundsOfCurve&&(c=[...arguments].join(),_.boundsOfCurveCache[c]))return _.boundsOfCurveCache[c];const l=Math.sqrt,u=Math.abs,d=[],g=[[0,0],[0,0]];let f=6*t-12*s+6*r,p=-3*t+9*s-9*r+3*a,m=3*s-3*t;for(let t=0;t<2;++t){if(t>0&&(f=6*e-12*i+6*n,p=-3*e+9*i-9*n+3*h,m=3*i-3*e),u(p)<1e-12){if(u(f)<1e-12)continue;const t=-m/f;0{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*S,d=nt(u),g=rt(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,T=-c*b*f/C,O=g*w-d*T+.5*t,k=d*w+g*T+.5*e;let D=Rr(1,0,(f-w)/C,(p-T)/b),M=Rr((f-w)/C,(p-T)/b,(-f-w)/C,(-p-T)/b);0===n&&M>0?M-=2*l:1===n&&M<0&&(M+=2*l);const P=Math.ceil(Math.abs(M/l*2)),E=[],A=M/P,j=8/3*Math.sin(A/4)*Math.sin(A/4)/Math.sin(A/2);let F=D+A;for(let t=0;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;case"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":Br(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},Yr=(t,e,s,i)=>Math.sqrt((s-t)**2+(i-e)**2),Wr=(t,e,s,i,r,n,o,a)=>h=>{const c=h**3,l=(t=>3*t**2*(1-t))(h),u=(t=>3*t*(1-t)**2)(h),d=(t=>(1-t)**3)(h);return new ot(o*c+r*l+s*u+t*d,a*c+n*l+i*u+e*d)},Vr=t=>t**2,zr=t=>2*t*(1-t),Hr=t=>(1-t)**2,Gr=(t,e,s,i,r,n,o,a)=>h=>{const c=Vr(h),l=zr(h),u=Hr(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)},Nr=(t,e,s,i,r,n)=>o=>{const a=Vr(o),h=zr(o),c=Hr(o);return new ot(r*a+s*h+t*c,n*a+i*h+e*c)},Ur=(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)},qr=(t,e,s)=>{let i=new ot(e,s),r=0;for(let e=1;e<=100;e+=1){const s=t(e/100);r+=Yr(i.x,i.y,s.x,s.y),i=s}return r},Kr=(t,e)=>{let i,r=0,n=0,o={x:t.x,y:t.y},a=s({},o),h=.01,c=0;const l=t.iterator,u=t.angleFinder;for(;n1e-4;)a=l(r),c=r,i=Yr(o.x,o.y,a.x,a.y),i+n>e?(r-=h,h/=2):(o=a,r+=h,n+=i);return s(s({},a),{},{angle:u(c)})},Jr=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=Yr(r,n,c[1],c[2]),r=c[1],n=c[2];break;case"C":e=Wr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s=t,s.iterator=e,s.angleFinder=Gr(r,n,c[1],c[2],c[3],c[4],c[5],c[6]),s.length=qr(e,r,n),r=c[5],n=c[6];break;case"Q":e=Nr(r,n,c[1],c[2],c[3],c[4]),s=t,s.iterator=e,s.angleFinder=Ur(r,n,c[1],c[2],c[3],c[4]),s.length=qr(e,r,n),r=c[3],n=c[4];break;case"Z":s=t,s.destX=o,s.destY=a,s.length=Yr(r,n,o,a),r=o,n=a}i+=s.length,h.push(s)}return h.push({length:i,x:r,y:n}),h},Qr=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Jr(t),r=0;for(;e-i[r].length>0&&r{var e;const s=[],i=null!==(e=t.match(Zr))&&void 0!==e?e:[];for(const t of i){const e=t[0];if("z"===e||"Z"===e){s.push([e]);continue}const i=en[e.toLowerCase()];let r=[];if("a"===e||"A"===e){$r.lastIndex=0;for(let e=null;e=$r.exec(t);)r.push(...e.slice(1))}else r=t.match(tn)||[];for(let t=0;t0&&o?o:e;for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:0,s=new ot(t[0]),i=new ot(t[1]),r=1,n=0;const o=[],a=t.length,h=a>2;let c;for(h&&(r=t[2].xt[c-2].x?1:s.x===t[c-2].x?0:-1,n=s.y>t[c-2].y?1:s.y===t[c-2].y?0:-1),o.push(["L",s.x+r*e,s.y+n*e]),o},nn=(t,e)=>t.map((t=>t.map(((t,s)=>0===s||void 0===e?t:qt(t,e))).join(" "))).join(" ");function on(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)})))}const an=(t,e)=>Math.floor(Math.random()*(e-t+1))+t;function hn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=e.onComplete||C,i=new(v().XMLHttpRequest),r=e.signal,n=function(){i.abort()},o=function(){r&&r.removeEventListener("abort",n),i.onerror=i.ontimeout=C};if(r&&r.aborted)throw new c("request");return r&&r.addEventListener("abort",n,{once:!0}),i.onreadystatechange=function(){4===i.readyState&&(o(),s(i),i.onreadystatechange=C)},i.onerror=i.ontimeout=o,i.open("get",t,!0),i.send(),i}const cn=(t,e)=>{let s=t._findCenterFromElement();t.transformMatrix&&((t=>{if(t.transformMatrix){const{scaleX:e,scaleY:s,angle:i,skewX:r}=kt(t.transformMatrix);t.flipX=!1,t.flipY=!1,t.set(G,e),t.set(N,s),t.angle=i,t.skewX=r,t.skewY=0}})(t),s=s.transform(t.transformMatrix)),delete t.transformMatrix,e&&(t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,t.cropX=e.cropX,t.cropY=e.cropY,s.x+=e.offsetLeft,s.y+=e.offsetTop,t.width=e.width,t.height=e.height),t.setPositionByOrigin(s,D,D)};var ln=Object.freeze({__proto__:null,addTransformToObject:ye,animate:As,animateColor:js,applyTransformToObject:_e,calcAngleBetweenVectors:ss,calcDimensionsMatrix:Ft,calcPlaneChangeMatrix:we,calcVectorRotation:is,cancelAnimFrame:dt,capValue:ds,composeMatrix:Lt,copyCanvasElement:t=>{var e;const s=vt(t);return null===(e=s.getContext("2d"))||void 0===e||e.drawImage(t,0,0),s},cos:rt,createCanvasElement:pt,createImage:mt,createRotateMatrix:Mt,createScaleMatrix:Pt,createSkewXMatrix:At,createSkewYMatrix:jt,createTranslateMatrix:Dt,createVector:ts,crossProduct:os,degreesToRadians:_t,dotProduct:as,ease:Cs,enlivenObjectEnlivables:Bt,enlivenObjects:It,findScaleToCover:Pr,findScaleToFit:Mr,getBoundsOfCurve:Ir,getOrthonormalVector:ns,getPathSegmentsInfo:Jr,getPointOnPath:Qr,getPointer:ge,getRandomInt:an,getRegularPolygonPath:(t,e)=>{const s=2*Math.PI/t;let i=-b;t%2==0&&(i+=s/2);const r=new Array(t+1);for(let n=0;n{const e=["instantiated_by_use","style","id","class"];switch(t){case"linearGradient":return e.concat(["x1","y1","x2","y2","gradientUnits","gradientTransform"]);case"radialGradient":return e.concat(["gradientUnits","gradientTransform","cx","cy","r","fx","fy","fr"]);case"stop":return e.concat(["offset","stop-color","stop-opacity"])}return e},getUnitVector:rs,groupSVGElements:(t,e)=>t&&1===t.length?t[0]:new Dr(t,e),hasStyleChanged:Pi,invertTransform:wt,isBetweenVectors:hs,isIdentityMatrix:Ct,isTouchEvent:fe,isTransparent:_i,joinPath:nn,loadImage:Rt,magnitude:es,makeBoundingBoxFromPoints:me,makePathSimpler:Xr,matrixToSVG:Qt,mergeClipPaths:(t,e)=>{var s;let i=t,r=e;i.inverted&&!r.inverted&&(i=e,r=t),Oe(r,null===(s=r.group)||void 0===s?void 0:s.calcTransformMatrix(),i.calcTransformMatrix());const n=i.inverted&&r.inverted;return n&&(i.inverted=r.inverted=!1),new Dr([i],{clipPath:r,inverted:n})},multiplyTransformMatrices:St,multiplyTransformMatrixArray:Tt,parsePath:sn,parsePreserveAspectRatioAttribute:Jt,parseUnit:Kt,pick:Xt,projectStrokeOnPoints:Si,qrDecompose:kt,radiansToDegrees:xt,removeFromArray:it,removeTransformFromObject:(t,e)=>{const s=wt(e),i=St(s,t.calcOwnMatrix());_e(t,i)},removeTransformMatrixForSvgParsing:cn,request:hn,requestAnimFrame:ut,resetObjectTransform:xe,rotatePoint:(t,e,s)=>t.rotate(s,e),rotateVector:$e,saveObjectTransform:Ce,sendObjectToPlane:Oe,sendPointToPlane:Se,sendVectorToPlane:Te,setStyle:on,sin:nt,sizeAfterTransform:be,string:Mi,stylesFromArray:Ai,stylesToArray:Ei,toDataURL:yt,toFixed:qt,transformPath:(t,e,s)=>(s&&(e=St(e,[1,0,0,1,-s.x,-s.y])),t.map((t=>{const s=[...t];for(let i=1;i1&&void 0!==arguments[1]?arguments[1]:{};super(e),t(this,"upper",void 0),t(this,"container",void 0);const{el:r}=this.lower,n=this.createUpperCanvas();this.upper={el:n,ctx:n.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:s}),this.applyCanvasStyle(n,{allowTouchScrolling:s,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,n),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=pt();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=m().createElement("div");return t.setAttribute("data-fabric","wrapper"),on(t,{position:"relative"}),he(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:r}=e;on(t,s(s({},i),{},{"touch-action":r?"manipulation":j})),he(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:s,ctx:i}=this.upper;oe(s,i,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),ae(this.upper.el,t),ae(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(),p().dispose(this.upper.el),delete this.upper,delete this.container}}class dn extends ue{constructor(){super(...arguments),t(this,"targets",[]),t(this,"_hoveredTargets",[]),t(this,"_objectsToRender",void 0),t(this,"_currentTransform",null),t(this,"_groupSelector",null),t(this,"contextTopDirty",!1)}static getDefaults(){return s(s({},super.getDefaults()),dn.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 un(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)}isTargetTransparent(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 _i(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===H||e===G||e===N||e===Y?i=this.centeredScaling||t.centeredScaling:e===B&&(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=A:["mr","tr","br"].includes(e)&&(s.x=M),["tl","mt","tr"].includes(e)?s.y=E:["bl","mb","br"].includes(e)&&(s.y=P),s):s}_setupCurrentTransform(t,e,i){var r;const n=e.group?Se(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},h=i&&a?null===(r=a.getActionHandler(t,e,a))||void 0===r?void 0:r.bind(a):Ie,c=((t,e,s,i)=>{if(!e||!t)return"drag";const r=i.controls[e];return r.getActionName(s,r,i)})(i,o,t,e),l=t[this.centeredKey],u=this._shouldCenterTransform(e,c,l)?{x:D,y:D}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:h,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:n.x-e.left,offsetY:n.y-e.top,originX:u.x,originY:u.y,ex:n.x,ey:n.y,lastX:n.x,lastY:n.y,theta:_t(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:l,original:s(s({},Ce(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:s,deltaX:i,deltaY:r}=this._groupSelector,n=new ot(e,s).transform(this.viewportTransform),o=new ot(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,yi.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,fe(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=rt(o)*r,h=nt(o)*r,c=a+h,l=a-h;s=[new ot(t.x-l,t.y-c),new ot(e.x+c,e.y-l),new ot(i.x+l,i.y+c),new ot(n.x-c,n.y+l)]}return Fs.isPointInPolygon(e,s)}_checkTarget(t,e){if(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,Se(e,void 0,this.viewportTransform))){if(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing)return!0;if(!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(ht(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&&ht(s)&&s.interactive&&this.targets[0]){const t=this.targets;for(let e=t.length-1;e>0;e--){const s=t[e];if(!ht(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=ge(t),n=i.width||0,o=i.height||0;n&&o||(P in i&&E in i&&(o=Math.abs(i.top-i.bottom)),A in i&&M 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=Se(r,void 0,this.viewportTransform));const a=this.getRetinaScaling();1!==a&&(r.x/=a,r.y/=a);const h=0===n||0===o?new ot(1,1):new ot(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=pt(),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 se(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,se(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),se(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(Q,i))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;se(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&&se(e)&&this._activeObject===e){const s=Xt(t,["angle","flipX","flipY",M,G,N,U,q,P]);return ye(t,e.calcOwnMatrix()),s}return{}}_setSVGObject(t,e,s){const i=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,s),e.set(i)}}t(dn,"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,hoverCursor:"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 gn{constructor(e){t(this,"targets",[]),t(this,"__disposer",void 0);const s=()=>{const{hiddenTextarea:t}=e.getActiveObject()||{};t&&t.focus()},i=e.upperCanvasEl;i.addEventListener("click",s),this.__disposer=()=>i.removeEventListener("click",s)}exitTextEditing(){this.target=void 0,this.targets.forEach((t=>{t.isEditing&&t.exitEditing()}))}add(t){this.targets.push(t)}remove(t){this.unregister(t),it(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 fn=["target","oldTarget","fireCanvas","e"],pn={passive:!1},mn=(t,e)=>{const s=t.getViewportPoint(e),i=t.getScenePoint(e);return{viewportPoint:s,scenePoint:i,pointer:s,absolutePointer:i}},vn=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i1?e-1:0),i=1;i1&&void 0!==arguments[1]?arguments[1]:{}),t(this,"_isClick",void 0),t(this,"textEditingManager",new gn(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach((t=>{this[t]=this[t].bind(this)})),this.addOrRemove(vn,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const s=this.upperCanvasEl,i=this._getEventPrefix();t(ne(s),"resize",this._onResize),t(s,i+"down",this._onMouseDown),t(s,"".concat(i,"move"),this._onMouseMove,pn),t(s,"".concat(i,"out"),this._onMouseOut),t(s,"".concat(i,"enter"),this._onMouseEnter),t(s,"wheel",this._onMouseWheel),t(s,"contextmenu",this._onContextMenu),t(s,"dblclick",this._onDoubleClick),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,pn)}removeListeners(){this.addOrRemove(yn,"remove");const t=this._getEventPrefix(),e=re(this.upperCanvasEl);yn(e,"".concat(t,"up"),this._onMouseUp),yn(e,"touchend",this._onTouchEnd,pn),yn(e,"".concat(t,"move"),this._onMouseMove,pn),yn(e,"touchmove",this._onMouseMove,pn),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=s({e:t},mn(this,t));this.fire("mouse:out",s(s({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",s({},i)),this._hoveredTargets.forEach((t=>{this.fire("mouse:out",s(s({},i),{},{target:t})),t&&t.fire("mouseout",s({},i))})),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",s({e:t},mn(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 vn(this.upperCanvasEl,"drag",this._onDragProgress)}pe(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(),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!==j,s=e?this._activeObject:void 0,i={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:s};yn(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){this.targets=[];return{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 s=0;s0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),s=re(this.upperCanvasEl);yn(s,"touchend",this._onTouchEnd,pn),yn(s,"touchmove",this._onMouseMove,pn),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout((()=>{vn(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=re(this.upperCanvasEl);yn(t,"".concat(s,"up"),this._onMouseUp),yn(t,"".concat(s,"move"),this._onMouseMove,pn),vn(e,"".concat(s,"move"),this._onMouseMove,pn)}}_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");const 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),fe(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{s=t.hoverCursor||s})),this.setCursor(s)}handleMultiSelection(t,e){const s=this._activeObject,i=se(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(tt.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 ot(e,s),o=n.add(new ot(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=tt.getClass("ActiveSelection");this.setActiveObject(new e(l,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const Cn={x1:0,y1:0,x2:0,y2:0},bn=s(s({},Cn),{},{r1:0,r2:0}),wn=(t,e)=>isNaN(t)&&"number"==typeof e?e:t,Sn=/^(\d+\.\d+)%|(\d+)%$/;function Tn(t){return t&&Sn.test(t)}function On(t,e){const s="number"==typeof t?t:"string"==typeof t?parseFloat(t)/(Tn(t)?100:1):NaN;return ds(0,wn(s,e),1)}const kn=/\s*;\s*/,Dn=/\s*:\s*/;function Mn(t,e){let s,i;const r=t.getAttribute("style");if(r){const t=r.split(kn);""===t[t.length-1]&&t.pop();for(let e=t.length;e--;){const[r,n]=t[e].split(Dn).map((t=>t.trim()));"stop-color"===r?s=n:"stop-opacity"===r&&(i=n)}}const n=new Ut(s||t.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:On(t.getAttribute("offset"),0),color:n.toRgb(),opacity:wn(parseFloat(i||t.getAttribute("stop-opacity")||""),1)*n.getAlpha()*e}}function Pn(t,e){const s=[],i=t.getElementsByTagName("stop"),r=On(e,1);for(let t=i.length;t--;)s.push(Mn(i[t],r));return s}function En(t){return"linearGradient"===t.nodeName||"LINEARGRADIENT"===t.nodeName?"linear":"radial"}function An(t){return"userSpaceOnUse"===t.getAttribute("gradientUnits")?"pixels":"percentage"}function jn(t,e){return t.getAttribute(e)}function Fn(t,e){return function(t,e){let s,{width:i,height:r,gradientUnits:n}=e;return Object.keys(t).reduce(((e,o)=>{const a=t[o];return"Infinity"===a?s=1:"-Infinity"===a?s=0:(s="string"==typeof a?parseFloat(a):a,"string"==typeof a&&Tn(a)&&(s*=.01,"pixels"===n&&("x1"!==o&&"x2"!==o&&"r2"!==o||(s*=i),"y1"!==o&&"y2"!==o||(s*=r)))),e[o]=s,e}),{})}("linear"===En(t)?function(t){return{x1:jn(t,"x1")||0,y1:jn(t,"y1")||0,x2:jn(t,"x2")||"100%",y2:jn(t,"y2")||0}}(t):function(t){return{x1:jn(t,"fx")||jn(t,"cx")||"50%",y1:jn(t,"fy")||jn(t,"cy")||"50%",r1:0,x2:jn(t,"cx")||"50%",y2:jn(t,"cy")||"50%",r2:jn(t,"r")||"50%"}}(t),s(s({},e),{},{gradientUnits:An(t)}))}class Ln{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:r={},colorStops:n=[],offsetX:o=0,offsetY:a=0,gradientTransform:h,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:s(s({},"radial"===e?bn:Cn),r),colorStops:n,offsetX:o,offsetY:a,gradientTransform:h,id:c?"".concat(c,"_").concat(ft()):ft()})}addColorStop(t){for(const e in t){const s=new Ut(t[e]);this.colorStops.push({offset:parseFloat(e),color:s.toRgb(),opacity:s.getAlpha()})}return this}toObject(t){return s(s({},Xt(this,t)),{},{type:this.type,coords:s({},this.coords),colorStops:this.colorStops.map((t=>s({},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 i=[],r=this.gradientTransform?this.gradientTransform.concat():T.concat(),n="pixels"===this.gradientUnits?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map((t=>s({},t))).sort(((t,e)=>t.offset-e.offset));let a=-this.offsetX,h=-this.offsetY;var c;"objectBoundingBox"===n?(a/=t.width,h/=t.height):(a+=t.width/2,h+=t.height/2),(c=t)&&"function"==typeof c._renderPathCommands&&"percentage"!==this.gradientUnits&&(a-=t.pathOffset.x,h-=t.pathOffset.y),r[4]-=a,r[5]-=h;const l=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(n,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Qt(r),'"'),""].join(" ");if("linear"===this.type){const{x1:t,y1:e,x2:s,y2:r}=this.coords;i.push("\n')}else if("radial"===this.type){const{x1:t,y1:e,x2:s,y2:r,r1:n,r2:a}=this.coords,h=n>a;i.push("\n'),h&&(o.reverse(),o.forEach((t=>{t.offset=1-t.offset})));const c=Math.min(n,a);if(c>0){const t=c/Math.max(n,a);o.forEach((e=>{e.offset+=t*(1-e.offset)}))}}return o.forEach((t=>{let{color:e,offset:s,opacity:r}=t;i.push("\n')})),i.push("linear"===this.type?"":"","\n"),i.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 Ut(e).setAlpha(s).toRgba():e)})),a}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(s(s({},t),{},{colorStops:e?e.map((t=>s({},t))):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const r=An(t),n=e._findCenterFromElement();return new this(s({id:t.getAttribute("id")||void 0,type:En(t),coords:Fn(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Pn(t,i.opacity),gradientUnits:r,gradientTransform:nr(t.getAttribute("gradientTransform")||"")},"pixels"===r?{offsetX:e.width/2-n.x,offsetY:e.height/2-n.y}:{offsetX:0,offsetY:0}))}}t(Ln,"type","Gradient"),tt.setClass(Ln,"gradient"),tt.setClass(Ln,"linear"),tt.setClass(Ln,"radial");const Rn=["type","source","patternTransform"];class In{get type(){return"pattern"}set type(t){a("warn","Setting type has no effect",t)}constructor(e){t(this,"repeat","repeat"),t(this,"offsetX",0),t(this,"offsetY",0),t(this,"crossOrigin",""),this.id=ft(),Object.assign(this,e)}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:i}=this;return s(s({},Xt(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:qt(this.offsetX,o.NUM_FRACTION_DIGITS),offsetY:qt(this.offsetY,o.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=wn(this.offsetX/e,0),a=wn(this.offsetY/s,0),h="repeat-y"===r||"no-repeat"===r?1+Math.abs(o||0):wn(i.width/e,0),c="repeat-x"===r||"no-repeat"===r?1+Math.abs(a||0):wn(i.height/s,0);return[''),''),"",""].join("\n")}static async fromObject(t,e){let{type:r,source:n,patternTransform:o}=t,a=i(t,Rn);const h=await Rt(n,s(s({},e),{},{crossOrigin:a.crossOrigin}));return new this(s(s({},a),{},{patternTransform:o&&o.slice(0),source:h}))}}t(In,"type","Pattern"),tt.setClass(In),tt.setClass(In,"pattern");class Bn{constructor(e){t(this,"color","rgb(0, 0, 0)"),t(this,"width",1),t(this,"shadow",null),t(this,"strokeLineCap","round"),t(this,"strokeLineJoin","round"),t(this,"strokeMiterLimit",10),t(this,"strokeDashArray",null),t(this,"limitedToCanvasSize",!1),this.canvas=e}_setBrushStyles(t){t.strokeStyle=this.color,t.lineWidth=this.width,t.lineCap=this.strokeLineCap,t.miterLimit=this.strokeMiterLimit,t.lineJoin=this.strokeLineJoin,t.setLineDash(this.strokeDashArray||[])}_saveAndTransform(t){const e=this.canvas.viewportTransform;t.save(),t.transform(e[0],e[1],e[2],e[3],e[4],e[5])}needsFullRender(){return new Ut(this.color).getAlpha()<1||!!this.shadow}_setShadow(){if(!this.shadow||!this.canvas)return;const t=this.canvas,e=this.shadow,s=t.contextTop,i=t.getZoom()*t.getRetinaScaling();s.shadowColor=e.color,s.shadowBlur=e.blur*i,s.shadowOffsetX=e.offsetX*i,s.shadowOffsetY=e.offsetY*i}_resetShadow(){const t=this.canvas.contextTop;t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}_isOutSideCanvas(t){return t.x<0||t.x>this.canvas.getWidth()||t.y<0||t.y>this.canvas.getHeight()}}const Xn=["path","left","top"],Yn=["d"];class Wn extends yi{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{path:s,left:r,top:n}=e,o=i(e,Xn);super(),Object.assign(this,Wn.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),"number"==typeof r&&this.set(M,r),"number"==typeof n&&this.set(P,n)}_setPath(t,e){this.path=Xr(Array.isArray(t)?t:sn(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new ot(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"#")}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(s({},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=nn(this.path,o.NUM_FRACTION_DIGITS);return["\n')]}_getOffsetTransform(){const t=o.NUM_FRACTION_DIGITS;return" translate(".concat(qt(-this.pathOffset.x,t),", ").concat(qt(-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,D,D)}_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(...Ir(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(...Ir(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 me(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return s(s({},t),{},{pathOffset:new ot(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,r){const n=ur(t,this.ATTRIBUTE_NAMES,r),{d:o}=n;return new this(o,s(s(s({},i(n,Yn)),e),{},{left:void 0,top:void 0}))}}t(Wn,"type","Path"),t(Wn,"cacheProperties",[...fs,"path","fillRule"]),t(Wn,"ATTRIBUTE_NAMES",[...ji,"d"]),tt.setClass(Wn),tt.setSVGClass(Wn);class Vn extends Bn{constructor(e){super(e),t(this,"decimate",.4),t(this,"drawStraightLine",!1),t(this,"straightLineKey","shiftKey"),this._points=[],this._hasStraightLine=!1}needsFullRender(){return super.needsFullRender()||this._hasStraightLine}static drawSegment(t,e,s){const i=e.midPointFrom(s);return t.quadraticCurveTo(e.x,e.y,i.x,i.y),i}onMouseDown(t,e){let{e:s}=e;this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],this._prepareForDrawing(t),this._addPoint(t),this._render())}onMouseMove(t,e){let{e:s}=e;if(this.canvas._isMainEvent(s)&&(this.drawStraightLine=!!this.straightLineKey&&s[this.straightLineKey],(!0!==this.limitedToCanvasSize||!this._isOutSideCanvas(t))&&this._addPoint(t)&&this._points.length>1))if(this.needsFullRender())this.canvas.clearContext(this.canvas.contextTop),this._render();else{const t=this._points,e=t.length,s=this.canvas.contextTop;this._saveAndTransform(s),this.oldEnd&&(s.beginPath(),s.moveTo(this.oldEnd.x,this.oldEnd.y)),this.oldEnd=Vn.drawSegment(s,t[e-2],t[e-1]),s.stroke(),s.restore()}}onMouseUp(t){let{e:e}=t;return!this.canvas._isMainEvent(e)||(this.drawStraightLine=!1,this.oldEnd=void 0,this._finalizeAndAddPath(),!1)}_prepareForDrawing(t){this._reset(),this._addPoint(t),this.canvas.contextTop.moveTo(t.x,t.y)}_addPoint(t){return!(this._points.length>1&&t.eq(this._points[this._points.length-1]))&&(this.drawStraightLine&&this._points.length>1&&(this._hasStraightLine=!0,this._points.pop()),this._points.push(t),!0)}_reset(){this._points=[],this._setBrushStyles(this.canvas.contextTop),this._setShadow(),this._hasStraightLine=!1}_render(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.canvas.contextTop,e=this._points[0],s=this._points[1];if(this._saveAndTransform(t),t.beginPath(),2===this._points.length&&e.x===s.x&&e.y===s.y){const t=this.width/1e3;e.x-=t,s.x+=t}t.moveTo(e.x,e.y);for(let i=1;i=n&&(i=t[e],a.push(i));return a.push(t[o]),a}_finalizeAndAddPath(){this.canvas.contextTop.closePath(),this.decimate&&(this._points=this.decimatePoints(this._points,this.decimate));const t=this.convertPointsToSVGPath(this._points);if(function(t){return"M 0 0 Q 0 0 0 0 L 0 0"===nn(t)}(t))return void this.canvas.requestRenderAll();const e=this.createPath(t);this.canvas.clearContext(this.canvas.contextTop),this.canvas.fire("before:path:created",{path:e}),this.canvas.add(e),this.canvas.requestRenderAll(),e.setCoords(),this._resetShadow(),this.canvas.fire("path:created",{path:e})}}const zn=["left","top","radius"],Hn=["radius","startAngle","endAngle","counterClockwise"];class Gn extends yi{static getDefaults(){return s(s({},super.getDefaults()),Gn.ownDefaults)}constructor(t){super(),Object.assign(this,Gn.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,_t(this.startAngle),_t(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(G)}getRadiusY(){return this.get("radius")*this.get(N)}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([...Hn,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(0===t)return["\n'];{const{radius:e}=this,s=_t(this.startAngle),i=_t(this.endAngle),r=rt(s)*e,n=nt(s)*e,o=rt(i)*e,a=nt(i)*e,h=t>180?1:0,c=this.counterClockwise?0:1;return['\n"]}}static async fromElement(t,e,r){const n=ur(t,this.ATTRIBUTE_NAMES,r),{left:o=0,top:a=0,radius:h=0}=n;return new this(s(s({},i(n,zn)),{},{radius:h,left:o-h,top:a-h}))}static fromObject(t){return super._fromObject(t)}}t(Gn,"type","Circle"),t(Gn,"cacheProperties",[...fs,...Hn]),t(Gn,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),t(Gn,"ATTRIBUTE_NAMES",["cx","cy","r",...ji]),tt.setClass(Gn),tt.setSVGClass(Gn);class Nn extends Bn{constructor(e){super(e),t(this,"width",10),this.points=[]}drawDot(t){const e=this.addPoint(t),s=this.canvas.contextTop;this._saveAndTransform(s),this.dot(s,e),s.restore()}dot(t,e){t.fillStyle=e.fill,t.beginPath(),t.arc(e.x,e.y,e.radius,0,2*Math.PI,!1),t.closePath(),t.fill()}onMouseDown(t){this.points=[],this.canvas.clearContext(this.canvas.contextTop),this._setShadow(),this.drawDot(t)}_render(){const t=this.canvas.contextTop,e=this.points;this._saveAndTransform(t);for(let s=0;s0&&void 0!==arguments[0]?arguments[0]:[0,0,0,0],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),Object.assign(this,Zn.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(M,n),"number"==typeof o&&this.set(P,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}=me([{x:t,y:e},{x:s,y:i}]),h=new ot(r+o/2,n+a/2);this.setPositionByOrigin(h,D,D)}_set(t,e){return super._set(t,e),Qn.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;$t(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 ot((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return s(s({},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["\n')]}static async fromElement(t,e,s){const r=ur(t,this.ATTRIBUTE_NAMES,s),{x1:n=0,y1:o=0,x2:a=0,y2:h=0}=r;return new this([n,o,a,h],i(r,Kn))}static fromObject(t){let{x1:e,y1:r,x2:n,y2:o}=t,a=i(t,Jn);return this._fromObject(s(s({},a),{},{points:[e,r,n,o]}),{extraParam:"points"})}}t(Zn,"type","Line"),t(Zn,"cacheProperties",[...fs,...Qn]),t(Zn,"ATTRIBUTE_NAMES",ji.concat(Qn)),tt.setClass(Zn),tt.setSVGClass(Zn);class $n extends yi{static getDefaults(){return s(s({},super.getDefaults()),$n.ownDefaults)}constructor(t){super(),Object.assign(this,$n.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["']}}t($n,"type","Triangle"),t($n,"ownDefaults",{width:100,height:100}),tt.setClass($n),tt.setSVGClass($n);const to=["rx","ry"];class eo extends yi{static getDefaults(){return s(s({},super.getDefaults()),eo.ownDefaults)}constructor(t){super(),Object.assign(this,eo.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(G)}getRy(){return this.get("ry")*this.get(N)}toObject(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject([...to,...t])}_toSVG(){return["\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,w,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,s){const i=ur(t,this.ATTRIBUTE_NAMES,s);return i.left=(i.left||0)-i.rx,i.top=(i.top||0)-i.ry,new this(i)}}function so(t){if(!t)return[];const e=t.replace(/,/g," ").trim().split(/\s+/),s=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[],s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),t(this,"strokeDiff",void 0),Object.assign(this,no.ownDefaults),this.setOptions(s),this.points=e;const{left:i,top:r}=s;this.initialized=!0,this.setBoundingBox(!0),"number"==typeof i&&this.set(M,i),"number"==typeof r&&this.set(P,r)}isOpen(){return!0}_projectStrokeOnPoints(t){return Si(this.points,t,this.isOpen())}_calcDimensions(t){t=s({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 ot,strokeOffset:new ot,strokeDiff:new ot};const i=me(e),r=Ft(s(s({},t),{},{scaleX:1,scaleY:1})),n=me(this.points.map((t=>bt(t,r,!0)))),o=new ot(this.scaleX,this.scaleY);let a=i.left+i.width/2,h=i.top+i.height/2;return this.exactBoundingBox&&(a-=h*Math.tan(_t(this.skewX)),h-=a*Math.tan(_t(this.skewY))),s(s({},i),{},{pathOffset:new ot(a,h),strokeOffset:new ot(n.left,n.top).subtract(new ot(i.left,i.top)).multiply(o),strokeDiff:new ot(i.width,i.height).subtract(new ot(n.width,n.height)).multiply(o)})}_findCenterFromElement(){const t=me(this.points);return new ot(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 ot(e+i/2,s+r/2),D,D)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new ot(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 ot(null!==(e=t.width)&&void 0!==e?e:i,null!==(s=t.height)&&void 0!==s?s:r)}else{var i,r;n=new ot(null!==(i=t.width)&&void 0!==i?i:this.width,null!==(r=t.height)&&void 0!==r?r:this.height)}return n.multiply(new ot(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===G||t===N)&&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 s(s({},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=o.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r\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;rvoid 0!==t));this._setStyleDeclaration(i,r,n)}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 s(s({},Xt(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]}}t(yo,"_styleProperties",uo);const _o=/ +/g,xo=/"/g;function Co(t,e,s,i,r){return"\t\t".concat(function(t,e){let{left:s,top:i,width:r,height:n}=e,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o.NUM_FRACTION_DIGITS;const h=Zt(K,t,!1),[c,l,u,d]=[s,i,r,n].map((t=>qt(t,a)));return"')}(t,{left:e,top:s,width:i,height:r}),"\n")}const bo=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let wo;class So extends yo{static getDefaults(){return s(s({},super.getDefaults()),So.ownDefaults)}constructor(e,s){super(),t(this,"__charBounds",[]),Object.assign(this,So.ownDefaults),this.setOptions(s),this.styles||(this.styles={}),this.text=e,this.initialized=!0,this.path&&this.setPathInfo(),this.initDimensions(),this.setCoords()}setPathInfo(){const t=this.path;t&&(t.segmentsInfo=Jr(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(fo)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,s,i,r,n,o;for(let a=0,h=this._textLines.length;a')}_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===J?(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 D:t.textBaseline="middle";break;case"ascender":t.textBaseline=P;break;case"descender":t.textBaseline=E}t.font=this._getFontDeclaration(e,s)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,s=this._textLines.length;et&&(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 e=0,r=this._textLines.length;e=0:ie?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=Qr(i.path,s,i.segmentsInfo);e.renderLeft=r.x-i.pathOffset.x,e.renderTop=r.y-i.pathOffset.y,e.angle=r.angle+(this.pathSide===A?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}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let s=1,i=this._textLines[t].length;s0){let e=i+u+f;"rtl"===this.direction&&(e=this.width-e-p),m&&v&&(t.fillStyle=v,t.fillRect(e,y+o*_+x,p,this.fontSize/15)),f=n.left,p=n.width,m=d,v=g,_=h,x=c}else p+=n.kernedWidth}let C=i+u+f;"rtl"===this.direction&&(C=this.width-C-p),t.fillStyle=g,d&&g&&t.fillRect(C,y+o*_+x,p-n,this.fontSize/15),s+=h}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(",")||So.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 ki(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),s=new Array(e.length),i=["\n"];let r=[];for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return s(s({},super.toObject([...lo,...t])),{},{styles:Ei(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 e in t)"path"===e&&this.setPathInfo(),i=i||s.includes(e),r=r||"path"===e;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,r){const n=ur(t,So.ATTRIBUTE_NAMES,r),o=s(s({},e),n),{textAnchor:a=M,textDecoration:h="",dx:c=0,dy:l=0,top:u=0,left:d=0,fontSize:g=O,strokeWidth:f=1}=o,p=i(o,bo),m=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),s({left:d+c,top:u+l,underline:h.includes("underline"),overline:h.includes("overline"),linethrough:h.includes("line-through"),strokeWidth:0,fontSize:g},p)),v=m.getScaledHeight()/m.height,y=((m.height+m.strokeWidth)*m.lineHeight-m.height)*v,_=m.getScaledHeight()+y;let x=0;return a===D&&(x=m.getScaledWidth()/2),a===A&&(x=m.getScaledWidth()),m.set({left:m.left-x,top:m.top-(_-m.fontSize*(.07+m._fontSizeFraction))/m.lineHeight,strokeWidth:f}),m}static fromObject(t){return this._fromObject(s(s({},t),{},{styles:Ai(t.styles||{},t.text)}),{extraParam:"text"})}}t(So,"textLayoutProperties",co),t(So,"cacheProperties",[...fs,...lo]),t(So,"ownDefaults",go),t(So,"type","Text"),t(So,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),t(So,"ATTRIBUTE_NAMES",ji.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),vi(So,[class extends Be{_toSVG(){const t=this._getSVGLeftTopOffsets(),e=this._getSVGTextAndBg(t.textTop,t.textLeft);return this._wrapSVGTextAndBg(e)}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,noStyle:!0,withShadow:!0})}_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",s.join(""),"\n"]}_getSVGTextAndBg(t,e){const s=[],i=[];let r,n=t;this.backgroundColor&&i.push(...Co(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let t=0,o=this._textLines.length;t").concat(Oi(t),"")}_setSVGTextLineText(t,e,s,i){const r=this.getHeightOfLine(e),n=this.textAlign.includes(fo),o=this._textLines[e];let a,h,c,l,u,d="",g=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let r=0,f=o.length-1;r<=f;r++)u=r===f||this.charSpacing,d+=o[r],c=this.__charBounds[e][r],0===g?(s+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,n&&!u&&this._reSpaceAndTab.test(o[r])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(e,r),h=this.getCompleteStyleDeclaration(e,r+1),u=Pi(a,h,!0)),u&&(l=this._getStyleDeclaration(e,r),t.push(this._createTextCharSpan(d,l,s,i)),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;lt[e.replace("-","")])).join(" ")}}]),tt.setClass(So),tt.setSVGClass(So);class To{constructor(e){t(this,"target",void 0),t(this,"__mouseDownInPlace",!1),t(this,"__dragStartFired",!1),t(this,"__isDraggingOver",!1),t(this,"__dragStartSelection",void 0),t(this,"__dragImageDisposer",void 0),t(this,"_dispose",void 0),this.target=e;const s=[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=()=>{s.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{_.remove()},re(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,i=this.isActive();if(i&&t.dataTransfer){const i=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(i.selectionStart,i.selectionEnd).join(""),n=s({text:e.text,value:r},i);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(i.selectionStart,i.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}return e.abortCursorAnimation(),i}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 es.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;if(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(z,{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)||j;o===j?(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(z,{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 Oo=/[ \n\.,;!\?\-]/;class ko extends So{constructor(){super(...arguments),t(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 As({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}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-1;)e++,s--;return t-e}findLineBoundaryRight(t){let e=0,s=t;for(;!/\n/.test(this._text[s])&&s0&&this._reSpace.test(s[t])&&(-1===e||!F.test(s[t-1]))?t-1:t,r=s[i];for(;i>0&&ithis.__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()))}_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;if(t===e)return{selectionStart:i,selectionEnd:i};return{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 ot(e.left+o,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new ot(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(Q),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=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,i,r){const n={},o=this._unwrappedTextLines[t].length,a=o===e;let h=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][0===e?e:e-1]:void 0;for(const s in this.styles[t]){const i=parseInt(s,10);i>=e&&(h=!0,n[i-e]=this.styles[t][s],a&&0===e||delete this.styles[t][s])}let l=!1;for(h&&!a&&(this.styles[t+i]=n,l=!0),(l||o>e)&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:s({},r[i-1])}:c?this.styles[t+i]={0:s({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,r){this.styles||(this.styles={});const n=this.styles[t],o=n?s({},n):{};i||(i=1);for(const t in o){const s=parseInt(t,10);s>=e&&(n[s+i]=o[s],o[s-i]||delete n[s])}if(this._forceClearCache=!0,r){for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=s({},r[i]));return}if(!n)return;const a=n[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=s({},a)}insertNewStyleBlock(t,e,s){const i=this.get2DCursorLocation(e,!0),r=[0];let n,o=0;for(let e=0;e0&&(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;n0?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=M:this._selectionDirection===A&&(this._selectionDirection=M,this.selectionEnd=t),this.selectionStart=s):s>t&&s{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,"; 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;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const s=()=>{this.updateFromTextArea(),this.fire(z),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(""===this.hiddenTextarea.value)return this.styles={},void s();const i=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,r=this._text.length,n=i.length,a=this.selectionStart,h=this.selectionEnd,c=a!==h;let l,u,d,g,f=n-r;const m=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),v=a>m.selectionStart;c?(u=this._text.slice(a,h),f+=h-a):nl[0]))),c?(d=a,g=h):v?(d=h-u.length,g=h):(d=h,g=h+u.length),this.removeStyleFromTo(d,g)),y.length){const{copyPasteData:t}=p();e&&y.join("")===t.copiedText&&!o.disableStyleCopyPaste&&(l=t.copiedTextStyle),this.insertNewStyleBlock(y,a,l)}s()}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}=p();t.copiedText=this.getSelectedText(),o.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;ae){r=!0;const t=n-i,s=n,h=Math.abs(t-e);o=Math.abs(s-e)=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===A);if(e.shiftKey?this.moveCursorWithShift(s):this.moveCursorWithoutShift(s),0!==s){const t=this.text.length;this.selectionStart=ds(0,this.selectionStart,t),this.selectionEnd=ds(0,this.selectionEnd,t),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===M?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;if(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=M,this.selectionEnd===this.selectionStart&&0!==this.selectionStart&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===A&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):0!==this.selectionStart?(this._selectionDirection=M,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===M&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=A,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=A,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Mo=t=>!!t.button;class Po extends Do{constructor(){super(...arguments),t(this,"draggableTextDelegate",void 0)}initBehavior(){this.on("mousedown",this._mouseDownHandler),this.on("mousedown:before",this._mouseDownHandlerBefore),this.on("mouseup",this.mouseUpHandler),this.on("mousedblclick",this.doubleClickHandler),this.on("tripleclick",this.tripleClickHandler),this.__lastClickTime=+new Date,this.__lastLastClickTime=+new Date,this.__lastPointer={},this.on("mousedown",this.onMouseDown),this.draggableTextDelegate=new To(this),super.initBehavior()}shouldStartDragging(){return this.draggableTextDelegate.isActive()}onDragStart(t){return this.draggableTextDelegate.onDragStart(t)}canDrop(t){return this.draggableTextDelegate.canDrop(t)}onMouseDown(t){if(!this.canvas)return;this.__newClickTime=+new Date;const e=t.pointer;this.isTripleClick(e)&&(this.fire("tripleclick",t),pe(t.e)),this.__lastLastClickTime=this.__lastClickTime,this.__lastClickTime=this.__newClickTime,this.__lastPointer=e,this.__lastSelected=this.selected&&!this.getActiveControl()}isTripleClick(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y}doubleClickHandler(t){this.isEditing&&this.selectWord(this.getSelectionStartFromPointer(t.e))}tripleClickHandler(t){this.isEditing&&this.selectLine(this.getSelectionStartFromPointer(t.e))}_mouseDownHandler(t){let{e:e}=t;this.canvas&&this.editable&&!Mo(e)&&!this.getActiveControl()&&(this.draggableTextDelegate.start(e)||(this.canvas.textEditingManager.register(this),this.selected&&(this.inCompositionMode=!1,this.setCursorByClick(e)),this.isEditing&&(this.__selectionStartOnMouseDown=this.selectionStart,this.selectionStart===this.selectionEnd&&this.abortCursorAnimation(),this.renderCursorOrSelection())))}_mouseDownHandlerBefore(t){let{e:e}=t;this.canvas&&this.editable&&!Mo(e)&&(this.selected=this===this.canvas._activeObject)}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||Mo(e)||i||(this.__lastSelected&&!this.getActiveControl()?(this.selected=!1,this.__lastSelected=!1,this.enterEditing(e),this.selectionStart===this.selectionEnd?this.initDelayedCursor(!0):this.renderCursorOrSelection()):this.selected=!0)}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(wt(this.calcTransformMatrix())).add(new ot(-this._getLeftOffset(),-this._getTopOffset()));let s=0,i=0,r=0;for(let t=0;t0&&(i+=this._textLines[t-1].length+this.missingNewlineOffset(t-1));let n=Math.abs(this._getLineLeftOffset(r));const o=this._textLines[r].length,a=this.__charBounds[r];for(let t=0;t0&&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)return;const t=this.clearContextTop(!0);if(!t)return;const e=this._getCursorBoundaries();this.selectionStart!==this.selectionEnd||this.inCompositionMode?this.renderSelection(t,e):this.renderCursor(t,e),this.canvas.contextTopDirty=!0,t.restore()}_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 t=0;t0?s:0)};return"rtl"===this.direction&&(this.textAlign===A||this.textAlign===fo||this.textAlign===mo?a.left*=-1:this.textAlign===M||this.textAlign===po?a.left=n-(s>0?s:0):this.textAlign!==D&&this.textAlign!==vo||(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(fo),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 e=h;e<=c;e++){const i=this._getLineLeftOffset(e)||0;let r=this.getHeightOfLine(e),o=0,a=0,d=0;if(e===h&&(a=this.__charBounds[h][l].left),e>=h&&e1)&&(r/=this.lineHeight);let g=s.left+i+a,f=r,p=0;const m=d-a;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",f=1,p=r):t.fillStyle=this.selectionColor,"rtl"===this.direction&&(this.textAlign===A||this.textAlign===fo||this.textAlign===mo?g=this.width-g-m:this.textAlign===M||this.textAlign===po?g=s.left+i-d:this.textAlign!==D&&this.textAlign!==vo||(g=s.left+i-d)),t.fillRect(g,s.top+s.topOffset+p,m,f),s.topOffset+=o}}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,K)}_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()}}t(Io,"ownDefaults",Ro),t(Io,"type","IText"),tt.setClass(Io),tt.setClass(Io,"i-text");class Bo extends Io{static getDefaults(){return s(s({},super.getDefaults()),Bo.ownDefaults)}constructor(t,e){super(t,s(s({},Bo.ownDefaults),e))}static createControls(){return{controls:pi()}}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(fo)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,s=0,i=0;const r={};for(let n=0;n0?(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 t in a)for(const i in a[t]){const n=parseInt(i,10);if(n>=s&&(!r||n{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;n3&&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;vp&&!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 t=0;t0&&void 0!==arguments[0]?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}t(Bo,"type","Textbox"),t(Bo,"textLayoutProperties",[...Io.textLayoutProperties,"width"]),t(Bo,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),tt.setClass(Bo);class Xo extends xr{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}=me(_r(s,i)),a=new ot(n,o);if(i.absolutePositioned){return{center:Se(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 ot,correction:i=new ot}=this.calcBoundingBox(e,t)||{};return{center:s.add(r),correction:i.subtract(r),size:a}}return{center:s.getRelativeCenterPoint().add(r),size:a}}}}t(Xo,"type","clip-path"),tt.setClass(Xo);class Yo extends xr{getInitialSize(t,e){let{target:s}=t,{size:i}=e;return new ot(s.width||i.x,s.height||i.y)}}t(Yo,"type","fixed"),tt.setClass(Yo);class Wo extends Tr{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 Vo extends Dr{static getDefaults(){return s(s({},super.getDefaults()),Vo.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,Vo.ownDefaults),this.setOptions(e);const{left:s,top:i,layoutManager:r}=e;this.groupInit(t,{left:s,top:i,layoutManager:null!=r?r:new Wo})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),s=0;s{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)))?(a("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)})),t===vr?s.forEach((t=>{t._onAfterObjectsChange(mr,e)})):s.forEach((t=>{t._set("dirty",!0)}))}onDeselect(){return this.removeAll(),!1}toString(){return"#")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const r=s(s({hasControls:!1},i),{},{forActiveSelection:!0});for(let e=0;e{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 Ho{constructor(){let{tileSize:e=o.textureSize}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),t(this,"resources",{}),this.tileSize=e,this.setupGLContext(e,e),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const s=vt({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 Go;function No(){const{WebGLProbe:t}=p();return t.queryWebGL(pt()),o.enableGLFiltering&&t.isSupported(o.textureSize)?new Ho({tileSize:o.textureSize}):new zo}function Uo(){return!Go&&(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])&&(Go=No()),Go}function qo(t){Go=t}const Ko=["filters","resizeFilter","src","crossOrigin","type"],Jo=["cropX","cropY"];class Qo extends yi{static getDefaults(){return s(s({},super.getDefaults()),Qo.ownDefaults)}constructor(e,s){super(),t(this,"_lastScaleX",1),t(this,"_lastScaleY",1),t(this,"_filterScalingX",1),t(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Qo.ownDefaults),this.setOptions(s),this.cacheKey="texture".concat(ft()),this.setElement("string"==typeof e?(this.canvas&&re(this.canvas.getElement())||m()).getElementById(e):e,s)}getElement(){return this._element}setElement(t){let e=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(e),t.classList.add(Qo.CSS_CANVAS),0!==this.filters.length&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Uo(!1);e instanceof Ho&&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&&p().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())})),s(s({},super.toObject([...Jo,...t])),{},{src:this.getSrc(),crossOrigin:this.getCrossOrigin(),filters:e},this.resizeFilter?{resizeFilter:this.resizeFilter.toObject()}:{})}hasCrop(){return!!this.cropX||!!this.cropY||this.width\n','\t\n',"\n"),o=' clip-path="url(#imageCrop_'+t+')" '}if(this.imageSmoothing||(a=' image-rendering="optimizeSpeed"'),t.push("\t\n")),this.stroke||this.strokeDashArray){const t=this.fill;this.fill=null,n=['\t\n')],this.fill=t}return r=this.paintFirst!==K?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 Rt(t,{crossOrigin:e,signal:s}).then((t=>{void 0!==e&&this.set({crossOrigin:e}),this.setElement(t)}))}toString(){return'#')}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=vt(n),{width:a,height:h}=n;this._element=o,this._lastScaleX=t.scaleX=i,this._lastScaleY=t.scaleY=r,Uo().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=vt({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);Uo().applyFilters(t,this._originalElement,s,i,this._element),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.naturalWidth||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=Jt(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===j&&t.alignY===j?(a=e/n,h=s/o):("meet"===t.meetOrSlice&&(a=h=Mr(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=Pr(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:r,resizeFilter:n,src:o,crossOrigin:a,type:h}=t,c=i(t,Ko);return Promise.all([Rt(o,s(s({},e),{},{crossOrigin:a})),r&&It(r,e),n&&It([n],e),Bt(c,e)]).then((t=>{let[e,i=[],[r]=[],n={}]=t;return new this(e,s(s({},c),{},{src:o,filters:i,resizeFilter:r},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 Rt(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=ur(t,this.ATTRIBUTE_NAMES,s);return this.fromURL(i["xlink:href"],e,i).catch((t=>(a("log","Unable to parse Image",t),null)))}}function Zo(t){if(!qe.test(t.nodeName))return{};const e=t.getAttribute("viewBox");let s,i,r=1,n=1,o=0,a=0;const h=t.getAttribute("width"),c=t.getAttribute("height"),l=t.getAttribute("x")||0,u=t.getAttribute("y")||0,d=!(e&&Je.test(e)),g=!h||!c||"100%"===h||"100%"===c;let f="",p=0,m=0;if(d&&(l||u)&&t.parentNode&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") ",s=(t.getAttribute("transform")||"")+f,t.setAttribute("transform",s),t.removeAttribute("x"),t.removeAttribute("y")),d&&g)return{width:0,height:0};const v={width:0,height:0};if(d)return v.width=Kt(h),v.height=Kt(c),v;const y=e.match(Je);o=-parseFloat(y[1]),a=-parseFloat(y[2]);const _=parseFloat(y[3]),x=parseFloat(y[4]);v.minX=o,v.minY=a,v.viewBoxWidth=_,v.viewBoxHeight=x,g?(v.width=_,v.height=x):(v.width=Kt(h),v.height=Kt(c),r=v.width/_,n=v.height/x);const C=Jt(t.getAttribute("preserveAspectRatio")||"");if(C.alignX!==j&&("meet"===C.meetOrSlice&&(n=r=r>n?n:r),"slice"===C.meetOrSlice&&(n=r=r>n?r:n),p=v.width-_*r,m=v.height-x*r,"Mid"===C.alignX&&(p/=2),"Mid"===C.alignY&&(m/=2),"Min"===C.alignX&&(p=0),"Min"===C.alignY&&(m=0)),1===r&&1===n&&0===o&&0===a&&0===l&&0===u)return v;if((l||u)&&"#document"!==t.parentNode.nodeName&&(f=" translate("+Kt(l||"0")+" "+Kt(u||"0")+") "),s=f+" matrix("+r+" 0 0 "+n+" "+(o*r+p)+" "+(a*n+m)+") ","svg"===t.nodeName){for(i=t.ownerDocument.createElementNS(Ve,"g");t.firstChild;)i.appendChild(t.firstChild);t.appendChild(i)}else i=t,i.removeAttribute("x"),i.removeAttribute("y"),s=i.getAttribute("transform")+s;return i.setAttribute("transform",s),v}t(Qo,"type","Image"),t(Qo,"cacheProperties",[...fs,...Jo]),t(Qo,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),t(Qo,"CSS_CANVAS","canvas-img"),t(Qo,"ATTRIBUTE_NAMES",[...ji,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),tt.setClass(Qo),tt.setSVGClass(Qo);const $o=t=>t.tagName.replace("svg:",""),ta=Xe(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);function ea(t,e){let s,i,r,n,o=[];for(r=0,n=e.length;r{const s=r.getAttribute(t);!e.hasAttribute(t)&&s&&e.setAttribute(t,s)})),!e.children.length)){const t=r.cloneNode(!0);for(;t.firstChild;)e.appendChild(t.firstChild)}e.removeAttribute(ia)}const na=["linearGradient","radialGradient","svg:linearGradient","svg:radialGradient"];function oa(t){const e=t.getElementsByTagName("style");let i,r;const n={};for(i=0,r=e.length;is.length>1&&t.trim())).forEach((t=>{if((t.match(/{/g)||[]).length>1&&t.trim().startsWith("@"))return;const e=t.split("{"),o={},a=e[1].trim().split(";").filter((function(t){return t.trim()}));for(i=0,r=a.length;i{""!==(t=t.replace(/^svg/i,"").trim())&&(n[t]=s(s({},n[t]||{}),o))}))}))}return n}const aa=t=>tt.getSVGClass($o(t).toLowerCase());class ha{constructor(t,e,s,i,r){this.elements=t,this.options=e,this.reviver=s,this.regexUrl=/^url\(['"]?#([^'"]+)['"]?\)/g,this.doc=i,this.clipPaths=r,this.gradientDefs=function(t){const e=ea(t,na),s={};let i=e.length;for(;i--;){const r=e[i];r.getAttribute("xlink:href")&&ra(t,r);const n=r.getAttribute("id");n&&(s[n]=r)}return s}(i),this.cssRules=oa(i)}parse(){return Promise.all(this.elements.map((t=>this.createObject(t))))}async createObject(t){const e=aa(t);if(e){const s=await e.fromElement(t,this.options,this.cssRules);return this.resolveGradient(s,t,K),this.resolveGradient(s,t,J),s instanceof Qo&&s._originalElement?cn(s,s.parsePreserveAspectRatioAttribute()):cn(s),await this.resolveClipPath(s,t),this.reviver&&this.reviver(t,s),s}return null}extractPropertyDefinition(t,e,s){const i=t[e],r=this.regexUrl;if(!r.test(i))return;r.lastIndex=0;const n=r.exec(i)[1];return r.lastIndex=0,s[n]}resolveGradient(t,e,i){const r=this.extractPropertyDefinition(t,i,this.gradientDefs);if(r){const n=e.getAttribute(i+"-opacity"),o=Ln.fromElement(r,t,s(s({},this.options),{},{opacity:n}));t.set(i,o)}}async resolveClipPath(t,e,s){const i=this.extractPropertyDefinition(t,"clipPath",this.clipPaths);if(i){const r=wt(t.calcTransformMatrix()),n=i[0].parentElement;let o=e;for(;!s&&o.parentElement&&o.getAttribute("clip-path")!==t.clipPath;)o=o.parentElement;o.parentElement.appendChild(n);const a=nr("".concat(o.getAttribute("transform")||""," ").concat(n.getAttribute("originalTransform")||""));n.setAttribute("transform","matrix(".concat(a.join(","),")"));const h=await Promise.all(i.map((t=>aa(t).fromElement(t,this.options,this.cssRules).then((t=>(cn(t),t.fillRule=t.clipRule,delete t.clipRule,t)))))),c=1===h.length?h[0]:new Dr(h),l=St(r,c.calcTransformMatrix());c.clipPath&&await this.resolveClipPath(c,o,n.getAttribute("clip-path")?o:void 0);const{scaleX:u,scaleY:d,angle:g,skewX:f,translateX:p,translateY:m}=kt(l);c.set({flipX:!1,flipY:!1}),c.set({scaleX:u,scaleY:d,angle:g,skewX:f,skewY:0}),c.setPositionByOrigin(new ot(p,m),D,D),t.clipPath=c}else delete t.clipPath}}const ca=t=>Ue.test($o(t)),la=()=>({objects:[],elements:[],options:{},allElements:[]});async function ua(t,e){let{crossOrigin:i,signal:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r&&r.aborted)return a("log",new c("parseSVGDocument")),la();const n=t.documentElement;!function(t){const e=ea(t,["use","svg:use"]),s=["x","y","xlink:href","href","transform"];for(const i of e){const e=i.attributes,r={};for(const t of e)t.value&&(r[t.name]=t.value);const n=(r["xlink:href"]||r.href||"").slice(1);if(""===n)return;const o=t.getElementById(n);if(null===o)return;let a=o.cloneNode(!0);const h=a.attributes,c={};for(const t of h)t.value&&(c[t.name]=t.value);const{x:l=0,y:u=0,transform:d=""}=r,g="".concat(d," ").concat(c.transform||""," translate(").concat(l,", ").concat(u,")");if(Zo(a),/^svg$/i.test(a.nodeName)){const t=a.ownerDocument.createElementNS(Ve,"g");Object.entries(c).forEach((e=>{let[s,i]=e;return t.setAttributeNS(Ve,s,i)})),t.append(...a.childNodes),a=t}for(const t of e){if(!t)continue;const{name:e,value:i}=t;if(!s.includes(e))if("style"===e){const t={};hr(i,t),Object.entries(c).forEach((e=>{let[s,i]=e;t[s]=i})),hr(c.style||"",t);const s=Object.entries(t).map((t=>t.join(":"))).join(";");a.setAttribute(e,s)}else!c[e]&&a.setAttribute(e,i)}a.setAttribute("transform",g),a.setAttribute("instantiated_by_use","1"),a.removeAttribute("id"),i.parentNode.replaceChild(a,i)}}(t);const o=Array.from(n.getElementsByTagName("*")),h=s(s({},Zo(n)),{},{crossOrigin:i,signal:r}),l=o.filter((t=>(Zo(t),ca(t)&&!function(t){let e=t;for(;e&&(e=e.parentElement);)if(e&&e.nodeName&&ta.test($o(e))&&!e.getAttribute("instantiated_by_use"))return!0;return!1}(t))));if(!l||l&&!l.length)return s(s({},la()),{},{options:h,allElements:o});const u={};o.filter((t=>"clipPath"===$o(t))).forEach((t=>{t.setAttribute("originalTransform",t.getAttribute("transform")||"");const e=t.getAttribute("id");u[e]=Array.from(t.getElementsByTagName("*")).filter((t=>ca(t)))}));const d=new ha(l,h,e,t,u);return{objects:await d.parse(),elements:l,options:h,allElements:o}}function da(t,e,s){return ua((new(v().DOMParser)).parseFromString(t.trim(),"text/xml"),e,s)}function ga(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((e,i)=>{hn(t.replace(/^\n\s*/,"").trim(),{onComplete:t=>{const s=t.responseXML;s&&e(s),i()},signal:s.signal})})).then((t=>ua(t,e,s))).catch((()=>la()))}const fa=W,pa=t=>function(e,s,i){const{points:r,pathOffset:n}=i;return new ot(r[t]).subtract(n).transform(St(i.getViewportTransform(),i.calcTransformMatrix()))},ma=(t,e,s,i)=>{const{target:r,pointIndex:n}=e,o=r,a=Se(new ot(s,i),void 0,o.calcOwnMatrix());return o.points[n]=a.add(o.pathOffset),o.setDimensions(),!0},va=(t,e)=>function(i,r,n,o){const a=r.target,h=new ot(a.points[(t>0?t:a.points.length)-1]),c=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()),l=e(i,s(s({},r),{},{pointIndex:t}),n,o),u=h.subtract(a.pathOffset).transform(a.calcOwnMatrix()).subtract(c);return a.left-=u.x,a.top-=u.y,l},ya=t=>Xs(fa,va(t,ma));const _a=(t,e,s)=>{const{path:i,pathOffset:r}=t,n=i[e];return new ot(n[s]-r.x,n[s+1]-r.y).transform(St(t.getViewportTransform(),t.calcTransformMatrix()))};function xa(t,e,s){const{commandIndex:i,pointIndex:r}=this;return _a(s,i,r)}function Ca(t,e,i,r){const{target:n}=e,{commandIndex:o,pointIndex:a}=this,h=((t,e,s,i,r)=>{const{path:n,pathOffset:o}=t,a=n[(i>0?i:n.length)-1],h=new ot(a[r],a[r+1]),c=h.subtract(o).transform(t.calcOwnMatrix()),l=Se(new ot(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})(n,i,r,o,a);return ke(this.actionName,s(s({},Fe(t,e,i,r)),{},{commandIndex:o,pointIndex:a})),h}class ba extends Hs{constructor(t){super(t)}render(t,e,i,r,n){const o=s(s({},r),{},{cornerColor:this.controlFill,cornerStrokeColor:this.controlStroke,transparentCorners:!this.controlFill});super.render(t,e,i,o,n)}}class wa extends ba{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=_a(r,h,c);if("Q"===l){const i=_a(r,o,a+2);t.moveTo(i.x,i.y),t.lineTo(e,s)}else t.moveTo(e,s);t.lineTo(u.x,u.y),t.stroke(),t.restore(),super.render(t,e,s,i,r)}}const Sa=(t,e,i,r,n,o)=>new(i?wa:ba)(s(s({commandIndex:t,pointIndex:e,actionName:"modifyPath",positionHandler:xa,actionHandler:Ca,connectToCommandIndex:n,connectToPointIndex:o},r),i?r.controlPointStyle:r.pointStyle));var Ta=Object.freeze({__proto__:null,changeWidth:Ws,createObjectDefaultControls:gi,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)]=Sa(r,t.length-2,!1,e)),n){case"C":s["c_".concat(r,"_C_CP_1")]=Sa(r,1,!0,e,r-1,(t=>"C"===t?5:"Q"===t?3:1)(i)),s["c_".concat(r,"_C_CP_2")]=Sa(r,3,!0,e,r,5);break;case"Q":s["c_".concat(r,"_Q_CP_1")]=Sa(r,1,!0,e,r,3)}i=n})),s},createPolyActionHandler:ya,createPolyControls:function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={};for(let r=0;r<("number"==typeof t?t:t.points.length);r++)i["p".concat(r)]=new Hs(s({actionName:fa,positionHandler:pa(r),actionHandler:ya(r)},e));return i},createPolyPositionHandler:pa,createResizeControls:fi,createTextboxDefaultControls:pi,dragHandler:Ie,factoryPolyActionHandler:va,getLocalPoint:Re,polyActionHandler:ma,renderCircleControl:Vs,renderSquareControl:zs,rotationStyleHandler:Gs,rotationWithSnapping:Ns,scaleCursorStyleHandler:Js,scaleOrSkewActionName:ci,scaleSkewCursorStyleHandler:li,scalingEqually:Zs,scalingX:$s,scalingXOrSkewingY:ui,scalingY:ti,scalingYOrSkewingX:di,skewCursorStyleHandler:ri,skewHandlerX:oi,skewHandlerY:ai,wrapWithFireEvent:Xs,wrapWithFixedAnchor:Ys});const Oa=t=>void 0!==t.webgl,ka=(t,e)=>{const s=vt({width:t,height:e}),i=pt().getContext("webgl"),r={imageBuffer:new ArrayBuffer(t*e*4)},n={destinationWidth:t,destinationHeight:e,targetCanvas:s};let o;o=v().performance.now(),Ho.prototype.copyGLTo2D.call(r,i,n);const a=v().performance.now()-o;o=v().performance.now(),Ho.prototype.copyGLTo2DPutImageData.call(r,i,n);return a>v().performance.now()-o},Da="precision highp float",Ma="\n ".concat(Da,";\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }"),Pa=["type"],Ea=["type"],Aa=new RegExp(Da,"g");class ja{get type(){return this.constructor.type}constructor(){let t=i(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Pa);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Ma}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"}}=p();"highp"!==i&&(e=e.replace(Aa,Da.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 h("Vertex, fragment shader or program creation error");if(t.shaderSource(r,s),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new h("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 h("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 h('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;r1){const s=t.destinationWidth,i=t.destinationHeight;t.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){Oa(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=vt({width:e,height:s});t.helpLayer=i}}toObject(){const t=Object.keys(this.constructor.defaults||{});return s({type:this.type},t.reduce(((t,e)=>(t[e]=this[e],t)),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(i(t,Ea))}}t(ja,"type","BaseFilter"),t(ja,"uniformLocations",[]);const Fa={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 La extends ja{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(Fa[this.mode],"\n }\n }\n ")}applyTo2d(t){let{imageData:{data:e}}=t;const s=new Ut(this.color).getSource(),i=this.alpha,r=s[0]*i,n=s[1]*i,o=s[2]*i,a=1-i;for(let t=0;tnew this(s(s({},o),{},{image:t}))))}}t(Ba,"type","BlendImage"),t(Ba,"defaults",{mode:"multiply",alpha:1}),t(Ba,"uniformLocations",["uTransformMatrix","uImage"]),tt.setClass(Ba);class Xa extends ja{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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n "}applyTo(t){Oa(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){t.imageData=this.simpleBlur(t)}simpleBlur(t){let{ctx:e,imageData:s,filterBackend:{resources:i}}=t;const{width:r,height:n}=s;i.blurLayer1||(i.blurLayer1=pt(),i.blurLayer2=pt());const o=i.blurLayer1,a=i.blurLayer2;o.width===r&&o.height===n||(a.width=o.width=r,a.height=o.height=n);const h=o.getContext("2d"),c=a.getContext("2d"),l=15,u=.06*this.blur*.5;let d,g,f,p;for(h.putImageData(s,0,0),c.clearRect(0,0,r,n),p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*r+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,f,d),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);for(p=-15;p<=l;p++)d=(Math.random()-.5)/4,g=p/l,f=u*g*n+d,c.globalAlpha=1-Math.abs(g),c.drawImage(o,d,f),h.drawImage(a,0,0),c.globalAlpha=1,c.clearRect(0,0,a.width,a.height);e.drawImage(o,0,0);const m=e.getImageData(0,0,o.width,o.height);return h.globalAlpha=1,h.clearRect(0,0,o.width,o.height),m}sendUniformData(t,e){const s=this.chooseRightDelta();t.uniform2fv(e.uDelta,s)}isNeutralState(){return 0===this.blur}chooseRightDelta(){let t=1;const e=[0,0];this.horizontal?this.aspectRatio>1&&(t=1/this.aspectRatio):this.aspectRatio<1&&(t=this.aspectRatio);const s=t*this.blur*.12;return this.horizontal?e[0]=s:e[1]=s,e}}t(Xa,"type","Blur"),t(Xa,"defaults",{blur:0}),t(Xa,"uniformLocations",["uDelta"]),tt.setClass(Xa);class Ya extends ja{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 t=0;t0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Oa(t)&&(t.passes+=this.subFilters.length-1),this.subFilters.forEach((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=>tt.getClass(t.type).fromObject(t,e)))).then((t=>new this({subFilters:t})))}}t(Qa,"type","Composed"),tt.setClass(Qa);class Za extends ja{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 t=0;t=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 s(s({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}t(th,"type","Convolute"),t(th,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),t(th,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),tt.setClass(th);const eh="Gamma";class sh extends ja{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 t=0;t<256;t++)o.r[t]=255*Math.pow(t/255,i),o.g[t]=255*Math.pow(t/255,r),o.b[t]=255*Math.pow(t/255,n);for(let t=0;tr[0]&&i>r[1]&&o>r[2]&&s"\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){Oa(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=pt());const m=u.sliceByTwo;(m.width<1.5*e||m.height=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++y1&&n<-1||(l=2*n*n*n-3*n*n+1,l>0&&(s=4*(t+i*e),v+=l*c[s+3],g+=l,c[s+3]<255&&(l=l*c[s+3]/250),f+=l*c[s],p+=l*c[s+1],m+=l*c[s+2],d+=l))}}u[r]=f/d,u[r+1]=p/d,u[r+2]=m/d,u[r+3]=v/g}return l}}t(uh,"type","Resize"),t(uh,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),t(uh,"uniformLocations",["uDelta","uTaps"]),tt.setClass(uh);class dh extends ja{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 t=0;t;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport {\n isFiller,\n isSerializableFiller,\n isTextObject,\n} from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: neededX + ALIASING_LIMIT,\n height: neededY + ALIASING_LIMIT,\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n minCacheSize = config.minCacheSideLimit,\n width = dims.width,\n height = dims.height,\n zoomX = dims.zoomX,\n zoomY = dims.zoomY,\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n let drawingWidth,\n drawingHeight,\n shouldRedraw = dimensionsChanged || zoomChanged,\n additionalWidth = 0,\n additionalHeight = 0,\n shouldResizeCanvas = false;\n\n if (dimensionsChanged) {\n const canvasWidth = (this._cacheCanvas as HTMLCanvasElement).width,\n canvasHeight = (this._cacheCanvas as HTMLCanvasElement).height,\n sizeGrowing = width > canvasWidth || height > canvasHeight,\n sizeShrinking =\n (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) &&\n canvasWidth > minCacheSize &&\n canvasHeight > minCacheSize;\n shouldResizeCanvas = sizeGrowing || sizeShrinking;\n if (\n sizeGrowing &&\n !dims.capped &&\n (width > minCacheSize || height > minCacheSize)\n ) {\n additionalWidth = width * 0.1;\n additionalHeight = height * 0.1;\n }\n }\n if (isTextObject(this) && this.path) {\n shouldRedraw = true;\n shouldResizeCanvas = true;\n // IMHO in those lines we are using zoomX and zoomY not the this version.\n additionalWidth += this.getHeightOfLine(0) * this.zoomX!;\n additionalHeight += this.getHeightOfLine(0) * this.zoomY!;\n }\n if (shouldRedraw) {\n if (shouldResizeCanvas) {\n canvas.width = Math.ceil(width + additionalWidth);\n canvas.height = Math.ceil(height + additionalHeight);\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n drawingWidth = dims.x / 2;\n drawingHeight = dims.y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = undefined;\n this._pointer = undefined;\n this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n *\n * @param {string} property The property to compare between characters and text.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n // @ts-expect-error conspiracy theory of TS\n this[property as keyof this] = stylePropertyValue;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n // @ts-expect-error readonly\n ...pick(this, (this.constructor as typeof StyledText)._styleProperties),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n // @ts-expect-error legacy method calling pattern\n this[keyMap[e.keyCode]](e);\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapDown[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapUp[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\n\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n // @ts-expect-error in reality it is an IText instance\n this.draggableTextDelegate = new DraggableTextDelegate(this);\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n // @ts-expect-error is this a bug? should this be naturalWidth? or is this the pipeline state?\n (source as HTMLImageElement).originalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n // @ts-expect-error is this a bug? should this be naturalHeight? or is this the pipeline state?\n (source as HTMLImageElement).originalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const tr = source[0] * this.alpha;\n const tg = source[1] * this.alpha;\n const tb = source[2] * this.alpha;\n const alpha1 = 1 - this.alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n break;\n case 'screen':\n data[i] = 255 - ((255 - r) * (255 - tr)) / 255;\n data[i + 1] = 255 - ((255 - g) * (255 - tg)) / 255;\n data[i + 2] = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n data[i] = r + tr;\n data[i + 1] = g + tg;\n data[i + 2] = b + tb;\n break;\n case 'difference':\n data[i] = Math.abs(r - tr);\n data[i + 1] = Math.abs(g - tg);\n data[i + 2] = Math.abs(b - tb);\n break;\n case 'subtract':\n data[i] = r - tr;\n data[i + 1] = g - tg;\n data[i + 2] = b - tb;\n break;\n case 'darken':\n data[i] = Math.min(r, tr);\n data[i + 1] = Math.min(g, tg);\n data[i + 2] = Math.min(b, tb);\n break;\n case 'lighten':\n data[i] = Math.max(r, tr);\n data[i + 1] = Math.max(g, tg);\n data[i + 2] = Math.max(b, tb);\n break;\n case 'overlay':\n data[i] =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n data[i + 1] =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n data[i + 2] =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n data[i] = tr + r - (2 * tr * r) / 255;\n data[i + 1] = tg + g - (2 * tg * g) / 255;\n data[i + 2] = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n data[i] = tr + r * alpha1;\n data[i + 1] = tg + g * alpha1;\n data[i + 2] = tb + b * alpha1;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = data[i] + brightness;\n data[i + 1] = data[i + 1] + brightness;\n data[i + 2] = data[i + 2] + brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\ntype ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n if (colorsOnly) {\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n } else {\n const a = data[i + 3];\n data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255;\n data[i + 2] =\n r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255;\n data[i + 3] =\n r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject() {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","export const fragmentSource = `\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 }`;\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n //@ts-expect-error TS wants matrix to be exported.\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<'Composed', ComposedOwnProps> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n //@ts-expect-error TS doesn't like this toObject\n toObject(): {\n type: 'Composed';\n subFilters: ReturnType['toObject']>[];\n } {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = `\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 }`;\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n switch (this.mode) {\n case 'average':\n value = (data[i] + data[i + 1] + data[i + 2]) / 3;\n break;\n case 'lightness':\n value =\n (Math.min(data[i], data[i + 1], data[i + 2]) +\n Math.max(data[i], data[i + 1], data[i + 2])) /\n 2;\n break;\n case 'luminosity':\n value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2];\n break;\n }\n\n data[i] = value;\n data[i + 1] = value;\n data[i + 2] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport { ColorMatrix } from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];\n this.matrix[0] = cosine + OneMinusCos / 3;\n this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[6] = cosine + aThird * OneMinusCos;\n this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[12] = cosine + aThird * OneMinusCos;\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n //@ts-expect-error TS and classes with different methods\n toObject(): { type: 'HueRotation'; rotation: number } {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentSource = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","export const fragmentShader = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n data[i] += max !== data[i] ? (max - data[i]) * adjust : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n const avg = (data[i] + data[i + 1] + data[i + 2]) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== data[i] ? (max - data[i]) * amt : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n","export const fragmentSource = `\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`;\n"],"names":["BaseConfiguration","constructor","_defineProperty","this","window","devicePixelRatio","config","super","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","env","setEnv","value","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","VERSION","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","classRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","runningAnimations","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","idx","cos","angle","abs","sin","angleSlice","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","element","createElement","createImage","createCanvasElementFor","newCanvas","toDataURL","canvasEl","format","quality","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","parseAngletoDegrees","fromHex","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","parseUnit","fontSize","unit","exec","dpi","DPI","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","align","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","colorValue","opacityValue","inlineStyle","toLive","opacity","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","_renderText","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","getElementOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","drawImage","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","version","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getPointer","event","scroll","_evt","touchProp","changedTouches","getTouchInfo","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","addTransformToObject","applyTransformToObject","calcOwnMatrix","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","sendPointToPlane","to","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","control","cornerAngle","getTotalAngle","getLocalPoint","corner","controls","padding","localPoint","getRelativeCenterPoint","translateToGivenOrigin","normalizePoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","Shadow","parseShadow","shadowStr","blur","replace","fBoxX","fBoxY","affectStroke","nonScaling","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","inverted","centeredRotation","centeredScaling","dirty","normalize","c","asin","elastic","defaultEasing","easeOutBounce","easeInBounce","easeInCirc","easeInCubic","easeInElastic","normA","normS","normP","easeInExpo","easeInOutBounce","easeInOutCirc","easeInOutCubic","easeInOutElastic","normC","easeInOutExpo","easeInOutQuad","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInQuad","easeInQuart","easeInQuint","easeInSine","easeOutCirc","easeOutCubic","easeOutElastic","easeOutExpo","easeOutQuad","easeOutQuart","easeOutQuint","easeOutSine","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","animate","isArrayAnimation","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersectsWithObject","intersection","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","w","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","minCacheSize","dimensionsChanged","zoomChanged","drawingWidth","drawingHeight","shouldRedraw","additionalWidth","additionalHeight","shouldResizeCanvas","canvasWidth","canvasHeight","sizeGrowing","getHeightOfLine","ceil","setTransform","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeWidth","changeObjectWidth","strokePadding","oldWidth","newWidth","renderCircleControl","styleOverride","xSize","sizeX","cornerSize","ySize","sizeY","transparentCorners","cornerStrokeColor","myLeft","myTop","cornerColor","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","cornerStyle","rotationStyleHandler","lockRotation","rotationWithSnapping","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","signX","signY","gestureScale","distance","original","oldScaleX","oldScaleY","scalingEqually","scaleObjectFromCorner","scalingX","scaleObjectX","scalingY","scaleObjectY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewHandler","axis","originKey","lockSkewingKey","skewKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingSide","finalHandler","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewObject","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","noScaleCache","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","hasControls","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","touchCornerSize","fn","selectionBackgroundColor","_activeObject","wh","strokeBorders","_drawBorders","borderColor","borderDashArray","drawControlsConnectingLines","_renderControls","hasBorders","styleOptions","shouldDrawBorders","shouldDrawControls","borderScaleFactor","isMoving","borderOpacityWhenMoving","drawBorders","forActiveSelection","shouldStroke","cornerDashArray","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","lockMovementX","lockMovementY","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","isTransparent","tolerance","getImageData","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","findIndexRight","cloneStyles","newObj","keyInner","escapeXml","string","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","charAt","next","prev","firstLetterOnly","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","elementMatchesRule","selectors","parentMatching","firstMatching","parentElement","doesSomeParentMatch","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleString","chunk","parseStyleAttribute","parseStyleObject","colorAttributesMap","parseAttributes","attributes","cssRules","parentFontSize","ownAttributes","rule","getGlobalStylesForElement","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","colorAttr","setStrokeFillOpacity","RECT_PROPS","Rect","_initRxRy","rx","ry","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","_context$x","_context$y","layoutObjects","layoutObject","_","bubblingContext","NoopLayoutManager","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","subTargetCheck","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","interactive","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","calcVectorAngle","ux","uy","vx","vy","ta","tb","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","large","sweep","tx","ty","segsNorm","arcToSegments","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","dtheta","segments","mDelta","th3","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","CB2","c3","CB3","c4","CB4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","tempInfo","totalLength","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","p2","multSignX","multSignY","manyPoints","midPoint","joinPath","pathData","setStyle","elementStyle","setProperty","getRandomInt","random","request","xhr","removeListener","ontimeout","onreadystatechange","readyState","open","send","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","_assignTransformMatrixProps","cropX","cropY","offsetLeft","offsetTop","_newCanvas$getContext","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","commonAttributes","groupSVGElements","mergeClipPaths","_b$group","removeTransformFromObject","finalTransform","rotatePoint","transformPath","pathOffset","pathSegment","newSegment","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","selection","_drawSelection","renderTop","setTargetFindTolerance","targetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","selectionKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","alreadySelected","_control$getActionHan","getScenePoint","getActionFromCorner","altKey","centeredKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","selectionLineWidth","minX","minY","maxX","maxY","selectionColor","selectionBorderColor","selectionDashArray","findTarget","skipTargetFind","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","originalValues","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_transformObject","_fireOverOutEvents","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","newActiveSelection","point1","point2","collectedObjects","klass","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","getValue","parseCoords","valuesToConvert","finalValue","propValue","convertPercentUnitsToValues","parseLinearCoords","parseRadialCoords","Gradient","addColorStop","colorStop","preTransform","sort","_renderPathCommands","needsSwap","minRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","cDistance","lastPoint","adjustedDistance","newPoints","decimate","isEmptySVGPath","CIRCLE_PROPS","Circle","setRadius","startAngle","endAngle","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","CircleBrush","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","SprayBrush","sprayChunks","sprayChunk","addSprayChunk","renderChunck","rects","chunck","rect","optimizeOverlapping","uniqueRects","uniqueRectsArray","getUniqueRects","sprayChunck","density","dotWidthVariance","dotWidth","randomOpacity","PatternBrush","getPatternSrc","patternCanvas","patternCtx","getPattern","pattern","topLeft","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","Triangle","widthBy2","heightBy2","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","letterCount","stylePropertyValue","stylesCount","allStyleObjectPropertiesMatch","graphemeCount","styleObject","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","svgColor","createSVGRect","measuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","__charBounds","kernedWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","leftOffset","_getLeftOffset","lineTopOffset","_getTopOffset","heightOfLine","lineLeftOffset","_getLineLeftOffset","drawStart","currentColor","boxWidth","boxStart","lastColor","getValueOfPropertyAt","charBox","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","getMeasuringContext","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","isJustify","shortCut","isLtr","currentDirection","actualStyle","nextStyle","timeToRender","drawingLeft","charsToRender","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","currentDecoration","currentFill","lastDecoration","lastFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","textDecoration","restOfOptions","textContent","textHeightScaleFactor","scaledDiff","textHeight","offX","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","textBgRects","textSpans","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","_getSVGLineTopOffset","lastHeight","useWhiteSpace","decoration","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","removeFrom","removeTo","charDiff","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","bound","widthBeforeCursor","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","getUpCursorOffset","textBeforeCursor","charWidth","foundMatch","widthOfCharsOnLine","indexOnLine","leftEdge","rightEdge","offsetFromLeftEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderSelection","renderCursor","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","Textbox","dynamicMinWidth","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","splitByGrapheme","isWrapping","nextOffset","nextLineIndex","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","_wordJoiners","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","minWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","ActiveSelection","multiSelectionStacking","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","pipelineState","imageData","originalEl","originalImageData","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","dWidth","dHeight","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","setFilterBackend","backend","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","imageSmoothing","getSvgSrc","origFill","filtered","srcFromAttribute","setSrc","minimumScale","minimumScaleTrigger","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","getMultipleNodes","nodeNames","nodeList","nodeArray","getElementsByTagNameNS","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","cloneNode","tagArray","getCSSRules","allRules","styleContents","ruleObj","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","gradientDefs","elList","getGradientDefs","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","async","parseSVGDocument","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","parseUseDirectives","descendants","hasInvalidAncestor","localClipPaths","elementParser","loadSVGFromString","parseFromString","loadSVGFromURL","xml","responseXML","parsedDoc","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","createPolyActionHandler","calcPathPointPosition","pathObject","commandIndex","pathPositionHandler","pathActionHandler","movePathPoint","anchorCommand","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","previousCommandType","indexFromPrevCommand","isWebGLPipelineState","isPutImageFaster","testContext","ArrayBuffer","testPipelineState","performance","now","drawImageTime","highPsourceCode","identityFragmentShader","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexSource","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","BlendColor","mode","tg","alpha1","uniform4fv","uColor","mask","BlendImage","image","TEXTURE1","calculateMatrix","resources","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","filterOptions","enlivedImage","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","Brightness","brightness","uBrightness","ColorMatrix","colorsOnly","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","Contrast","contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","Convolute","opaque","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","Gamma","gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","Grayscale","uMode","HueRotation","rotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","Invert","invert","uInvert","uAlpha","Noise","noise","rand","uNoise","uSeed","Pixelate","blocksize","_i","_j","uBlocksize","RemoveColor","lowC","highC","uLow","uHigh","useAlpha","Resize","uTaps","taps","getFilterWindow","tempScale","lanczosLobes","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","resizeType","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","srcData","destImg","destData","lanczos","ratioX","ratioY","rcpRatioX","rcpRatioY","range2X","range2Y","cacheLanc","icenter","process","u","weight","fX","fY","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","Saturation","adjust","saturation","uSaturation","Vibrance","vibrance","amt","uVibrance"],"mappings":"y9CAEA,MAAMA,EAAkBC,WAAAA,GACtBC,mCAc4B,GAE5BA,aAGM,IAENA,EAAAC,KAAA,mBAKoB,oBAAXC,OAAyBA,OAAOC,iBAAmB,GAE5DH,4BAMqB,SAErBA,2BAMoB,MAEpBA,2BAMoB,KAEpBA,gCAQwB,GAExBA,4BAQoB,GAEpBA,qBAUc,MAEdA,8BAOsB,GAEtBA,8BAQsB,GAEtBA,EAAAC,KAAA,YAIwE,CAAA,GAExED,6BAKsB,EAAC,QA8CZI,EAAS,IA3Cf,cAA4BN,EACjCC,WAAAA,CAAYK,GACVC,QACAJ,KAAKK,UAAUF,EACjB,CAEAE,SAAAA,GAAuC,IAA7BF,EAAsBG,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UA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KjpB,EAAI,IAAMk7G,EAAM,EACjEjyF,EAAKjpB,EAAI,IAAMtG,IAAQuvB,EAAKjpB,EAAI,IAAMtG,EAAMuvB,EAAKjpB,EAAI,IAAMk7G,EAAM,CACnE,CACF,CAQArO,eAAAA,CACEx1G,EACAszG,GAEAtzG,EAAGu1G,UAAUjC,EAAiBwQ,WAAYxmH,KAAKsmH,SACjD,CAEAxb,cAAAA,GACE,OAAyB,IAAlB9qG,KAAKsmH,QACd,EArDAvmH,EADWsmH,GAAQ,OAWL,YAAUtmH,EAXbsmH,GAAQ,WAbkC,CACrDC,SAAU,IAyB6BvmH,EAb5BsmH,GAee,mBAAA,CAAC,cA0C7Bj+G,GAAcM,SAAS29G"} \ No newline at end of file +{"version":3,"file":"index.min.mjs","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/util.ts","../src/color/Color.ts","../src/color/constants.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/findRight.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/elementMatchesRule.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/parseStyleObject.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/parser/getGlobalStylesForElement.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/util/misc/rotatePoint.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/CanvasOptions.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/brushes/CircleBrush.ts","../src/brushes/SprayBrush.ts","../src/brushes/PatternBrush.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/parseUseDirectives.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/Blur.ts","../src/filters/shaders/blur.ts","../src/filters/Brightness.ts","../src/filters/shaders/brightness.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/Contrast.ts","../src/filters/shaders/constrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/Invert.ts","../src/filters/shaders/invert.ts","../src/filters/Noise.ts","../src/filters/shaders/noise.ts","../src/filters/Pixelate.ts","../src/filters/shaders/pixelate.ts","../src/filters/RemoveColor.ts","../src/filters/shaders/removeColor.ts","../src/filters/Resize.ts","../src/filters/Saturation.ts","../src/filters/shaders/saturation.ts","../src/filters/Vibrance.ts","../src/filters/shaders/vibrance.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n color = color.toLowerCase();\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport { isFiller, isSerializableFiller } from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: Math.ceil(neededX + ALIASING_LIMIT),\n height: Math.ceil(neededY + ALIASING_LIMIT),\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n { width, height, zoomX, zoomY, x, y } = this._limitCacheSize(\n this._getCacheCanvasDimensions(),\n ),\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n const shouldRedraw = dimensionsChanged || zoomChanged;\n\n if (shouldRedraw) {\n if (width !== canvas.width || height !== canvas.height) {\n canvas.width = width;\n canvas.height = height;\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n const drawingWidth = x / 2;\n const drawingHeight = y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = this._pointer = this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n this[property as keyof this] = stylePropertyValue as any;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n ...pick(\n this,\n (this.constructor as typeof StyledText)\n ._styleProperties as (keyof this)[],\n ),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n (this[keyMap[e.keyCode] as keyof this] as (arg: KeyboardEvent) => void)(\n e,\n );\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapDown[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapUp[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport type { IText } from './IText';\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n this.draggableTextDelegate = new DraggableTextDelegate(\n this as unknown as IText,\n );\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n (source as HTMLImageElement).naturalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n (source as HTMLImageElement).naturalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n SerializedProps extends Record = OwnProps,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & SerializedProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof SerializedProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as SerializedProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const alpha = this.alpha;\n const tr = source[0] * alpha;\n const tg = source[1] * alpha;\n const tb = source[2] * alpha;\n const alpha1 = 1 - alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n let oR, oG, oB;\n switch (this.mode) {\n case 'multiply':\n oR = (r * tr) / 255;\n oG = (g * tg) / 255;\n oB = (b * tb) / 255;\n break;\n case 'screen':\n oR = 255 - ((255 - r) * (255 - tr)) / 255;\n oG = 255 - ((255 - g) * (255 - tg)) / 255;\n oB = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n oR = r + tr;\n oG = g + tg;\n oB = b + tb;\n break;\n case 'difference':\n oR = Math.abs(r - tr);\n oG = Math.abs(g - tg);\n oB = Math.abs(b - tb);\n break;\n case 'subtract':\n oR = r - tr;\n oG = g - tg;\n oB = b - tb;\n break;\n case 'darken':\n oR = Math.min(r, tr);\n oG = Math.min(g, tg);\n oB = Math.min(b, tb);\n break;\n case 'lighten':\n oR = Math.max(r, tr);\n oG = Math.max(g, tg);\n oB = Math.max(b, tb);\n break;\n case 'overlay':\n oR =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n oG =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n oB =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n oR = tr + r - (2 * tr * r) / 255;\n oG = tg + g - (2 * tg * g) / 255;\n oB = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n oR = tr + r * alpha1;\n oG = tg + g * alpha1;\n oB = tb + b * alpha1;\n }\n data[i] = oR;\n data[i + 1] = oG;\n data[i + 2] = oB;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] += brightness;\n data[i + 1] += brightness;\n data[i + 2] += brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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`;\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\nexport type ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n SerializedProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n if (!colorsOnly) {\n const a = data[i + 3];\n data[i] += a * m[3];\n data[i + 1] += a * m[8];\n data[i + 2] += a * m[13];\n data[i + 3] += a * m[18];\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject(): { type: Name } & SerializedProps {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix<\n typeof key,\n FixedFiltersOwnProps,\n FixedFiltersOwnProps\n > {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\ntype ComposedSerializedProps = {\n subFilters: Record[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<\n 'Composed',\n ComposedOwnProps,\n ComposedSerializedProps\n> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n toObject() {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = `\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 }`;\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n switch (this.mode) {\n case 'average':\n value = (r + g + b) / 3;\n break;\n case 'lightness':\n value = (Math.min(r, g, b) + Math.max(r, g, b)) / 2;\n break;\n case 'luminosity':\n value = 0.21 * r + 0.72 * g + 0.07 * b;\n break;\n }\n\n data[i + 2] = data[i + 1] = data[i] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport {\n ColorMatrix,\n type ColorMatrixOwnProps,\n colorMatrixDefaultValues,\n} from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = ColorMatrixOwnProps & {\n rotation: number;\n};\n\nexport type HueRotationSerializedProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n ...colorMatrixDefaultValues,\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps,\n HueRotationSerializedProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [\n cosine + OneMinusCos / 3,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n aThird * OneMinusCos - aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n 0,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n ];\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n toObject() {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentSource = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","export const fragmentShader = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n data[i] += max !== r ? (max - r) * adjust : 0;\n data[i + 1] += max !== g ? (max - g) * adjust : 0;\n data[i + 2] += max !== b ? (max - b) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n const avg = (r + g + b) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== r ? (max - r) * amt : 0;\n data[i + 1] += max !== g ? (max - g) * amt : 0;\n data[i + 2] += max !== b ? (max - b) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n","export const fragmentSource = `\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`;\n"],"names":["BaseConfiguration","constructor","_defineProperty","this","window","devicePixelRatio","config","super","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","env","setEnv","value","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","VERSION","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","classRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","runningAnimations","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","idx","cos","angle","abs","sin","angleSlice","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","element","createElement","createImage","createCanvasElementFor","newCanvas","toDataURL","canvasEl","format","quality","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","parseAngletoDegrees","fromHex","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","parseUnit","fontSize","unit","exec","dpi","DPI","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","align","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","colorValue","opacityValue","inlineStyle","toLive","opacity","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","getElementOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","drawImage","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","version","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","_renderText","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getPointer","event","scroll","_evt","touchProp","changedTouches","getTouchInfo","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","addTransformToObject","applyTransformToObject","calcOwnMatrix","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","sendPointToPlane","to","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","control","cornerAngle","getTotalAngle","getLocalPoint","corner","controls","padding","localPoint","getRelativeCenterPoint","translateToGivenOrigin","normalizePoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","Shadow","parseShadow","shadowStr","blur","replace","fBoxX","fBoxY","affectStroke","nonScaling","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","inverted","centeredRotation","centeredScaling","dirty","normalize","c","asin","elastic","defaultEasing","easeOutBounce","easeInBounce","easeInCirc","easeInCubic","easeInElastic","normA","normS","normP","easeInExpo","easeInOutBounce","easeInOutCirc","easeInOutCubic","easeInOutElastic","normC","easeInOutExpo","easeInOutQuad","easeInOutQuart","easeInOutQuint","easeInOutSine","easeInQuad","easeInQuart","easeInQuint","easeInSine","easeOutCirc","easeOutCubic","easeOutElastic","easeOutExpo","easeOutQuad","easeOutQuart","easeOutQuint","easeOutSine","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","animate","isArrayAnimation","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersectsWithObject","intersection","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","w","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","ceil","dimensionsChanged","zoomChanged","setTransform","drawingWidth","drawingHeight","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeWidth","changeObjectWidth","strokePadding","oldWidth","newWidth","renderCircleControl","styleOverride","xSize","sizeX","cornerSize","ySize","sizeY","transparentCorners","cornerStrokeColor","myLeft","myTop","cornerColor","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","getActionName","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","cornerStyle","rotationStyleHandler","lockRotation","rotationWithSnapping","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","signX","signY","gestureScale","distance","original","oldScaleX","oldScaleY","scalingEqually","scaleObjectFromCorner","scalingX","scaleObjectX","scalingY","scaleObjectY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewHandler","axis","originKey","lockSkewingKey","skewKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingSide","finalHandler","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewObject","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","noScaleCache","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","hasControls","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","touchCornerSize","fn","selectionBackgroundColor","_activeObject","wh","strokeBorders","_drawBorders","borderColor","borderDashArray","drawControlsConnectingLines","_renderControls","hasBorders","styleOptions","shouldDrawBorders","shouldDrawControls","borderScaleFactor","isMoving","borderOpacityWhenMoving","drawBorders","forActiveSelection","shouldStroke","cornerDashArray","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","lockMovementX","lockMovementY","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","isTransparent","tolerance","getImageData","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","findIndexRight","cloneStyles","newObj","keyInner","escapeXml","string","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","charAt","next","prev","firstLetterOnly","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","elementMatchesRule","selectors","parentMatching","firstMatching","parentElement","doesSomeParentMatch","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleString","chunk","parseStyleAttribute","parseStyleObject","colorAttributesMap","parseAttributes","attributes","cssRules","parentFontSize","ownAttributes","rule","getGlobalStylesForElement","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","colorAttr","setStrokeFillOpacity","RECT_PROPS","Rect","_initRxRy","rx","ry","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","_context$x","_context$y","layoutObjects","layoutObject","_","bubblingContext","NoopLayoutManager","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","subTargetCheck","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","interactive","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","calcVectorAngle","ux","uy","vx","vy","ta","tb","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","large","sweep","tx","ty","segsNorm","arcToSegments","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","dtheta","segments","mDelta","th3","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","CB2","c3","CB3","c4","CB4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","tempInfo","totalLength","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","p2","multSignX","multSignY","manyPoints","midPoint","joinPath","pathData","setStyle","elementStyle","setProperty","getRandomInt","random","request","xhr","removeListener","ontimeout","onreadystatechange","readyState","open","send","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","_assignTransformMatrixProps","cropX","cropY","offsetLeft","offsetTop","_newCanvas$getContext","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","commonAttributes","groupSVGElements","mergeClipPaths","_b$group","removeTransformFromObject","finalTransform","rotatePoint","transformPath","pathOffset","pathSegment","newSegment","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","selection","_drawSelection","renderTop","setTargetFindTolerance","targetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","selectionKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","alreadySelected","_control$getActionHan","getScenePoint","getActionFromCorner","altKey","centeredKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","selectionLineWidth","minX","minY","maxX","maxY","selectionColor","selectionBorderColor","selectionDashArray","findTarget","skipTargetFind","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","originalValues","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_transformObject","_fireOverOutEvents","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","newActiveSelection","point1","point2","collectedObjects","klass","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","getValue","parseCoords","valuesToConvert","finalValue","propValue","convertPercentUnitsToValues","parseLinearCoords","parseRadialCoords","Gradient","addColorStop","colorStop","preTransform","sort","_renderPathCommands","needsSwap","minRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","cDistance","lastPoint","adjustedDistance","newPoints","decimate","isEmptySVGPath","CIRCLE_PROPS","Circle","setRadius","startAngle","endAngle","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","CircleBrush","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","SprayBrush","sprayChunks","sprayChunk","addSprayChunk","renderChunck","rects","chunck","rect","optimizeOverlapping","uniqueRects","uniqueRectsArray","getUniqueRects","sprayChunck","density","dotWidthVariance","dotWidth","randomOpacity","PatternBrush","getPatternSrc","patternCanvas","patternCtx","getPattern","pattern","topLeft","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","Triangle","widthBy2","heightBy2","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","letterCount","stylePropertyValue","stylesCount","allStyleObjectPropertiesMatch","graphemeCount","styleObject","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","svgColor","createSVGRect","measuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","__charBounds","kernedWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","leftOffset","_getLeftOffset","lineTopOffset","_getTopOffset","heightOfLine","getHeightOfLine","lineLeftOffset","_getLineLeftOffset","drawStart","currentColor","boxWidth","boxStart","lastColor","getValueOfPropertyAt","charBox","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","getMeasuringContext","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","isJustify","shortCut","isLtr","currentDirection","actualStyle","nextStyle","timeToRender","drawingLeft","charsToRender","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","currentDecoration","currentFill","lastDecoration","lastFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","textDecoration","restOfOptions","textContent","textHeightScaleFactor","scaledDiff","textHeight","offX","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","textBgRects","textSpans","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","_getSVGLineTopOffset","lastHeight","useWhiteSpace","decoration","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","removeFrom","removeTo","charDiff","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","bound","widthBeforeCursor","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","getUpCursorOffset","textBeforeCursor","charWidth","foundMatch","widthOfCharsOnLine","indexOnLine","leftEdge","rightEdge","offsetFromLeftEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderSelection","renderCursor","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","Textbox","dynamicMinWidth","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","splitByGrapheme","isWrapping","nextOffset","nextLineIndex","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","_wordJoiners","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","minWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","ActiveSelection","multiSelectionStacking","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","pipelineState","imageData","originalEl","originalImageData","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","dWidth","dHeight","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","setFilterBackend","backend","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","imageSmoothing","getSvgSrc","origFill","filtered","srcFromAttribute","setSrc","minimumScale","minimumScaleTrigger","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","getMultipleNodes","nodeNames","nodeList","nodeArray","getElementsByTagNameNS","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","cloneNode","tagArray","getCSSRules","allRules","styleContents","ruleObj","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","gradientDefs","elList","getGradientDefs","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","async","parseSVGDocument","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","parseUseDirectives","descendants","hasInvalidAncestor","localClipPaths","elementParser","loadSVGFromString","parseFromString","loadSVGFromURL","xml","responseXML","parsedDoc","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","createPolyActionHandler","calcPathPointPosition","pathObject","commandIndex","pathPositionHandler","pathActionHandler","movePathPoint","anchorCommand","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","previousCommandType","indexFromPrevCommand","isWebGLPipelineState","isPutImageFaster","testContext","ArrayBuffer","testPipelineState","performance","now","drawImageTime","highPsourceCode","identityFragmentShader","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexSource","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","BlendColor","mode","tg","alpha1","oR","oG","oB","uniform4fv","uColor","mask","BlendImage","image","TEXTURE1","calculateMatrix","resources","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","filterOptions","enlivedImage","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","Brightness","brightness","uBrightness","colorMatrixDefaultValues","colorsOnly","ColorMatrix","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","Contrast","contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","Convolute","opaque","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","Gamma","gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","Grayscale","uMode","hueRotationDefaultValues","rotation","HueRotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","Invert","invert","uInvert","uAlpha","Noise","noise","rand","uNoise","uSeed","Pixelate","blocksize","_i","_j","uBlocksize","RemoveColor","lowC","highC","uLow","uHigh","useAlpha","Resize","uTaps","taps","getFilterWindow","tempScale","lanczosLobes","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","resizeType","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","srcData","destImg","destData","lanczos","ratioX","ratioY","rcpRatioX","rcpRatioY","range2X","range2Y","cacheLanc","icenter","process","u","weight","fX","fY","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","Saturation","adjust","saturation","uSaturation","Vibrance","vibrance","amt","uVibrance"],"mappings":"y9CAEA,MAAMA,EAAkBC,WAAAA,GACtBC,mCAc4B,GAE5BA,aAGM,IAENA,EAAAC,KAAA,mBAKoB,oBAAXC,OAAyBA,OAAOC,iBAAmB,GAE5DH,4BAMqB,SAErBA,2BAMoB,MAEpBA,2BAMoB,KAEpBA,gCAQwB,GAExBA,4BAQoB,GAEpBA,qBAUc,MAEdA,8BAOsB,GAEtBA,8BAQsB,GAEtBA,EAAAC,KAAA,YAIwE,CAAA,GAExED,6BAKsB,EAAC,QA8CZI,EAAS,IA3Cf,cAA4BN,EACjCC,WAAAA,CAAYK,GACVC,QACAJ,KAAKK,UAAUF,EACjB,CAEAE,SAAAA,GAAuC,IAA7BF,EAAsBG,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EACjCG,OAAOC,OAAOV,KAAMG,EACtB,CAKAQ,QAAAA,GAEE,IADAC,EAAiEN,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAEpEN,KAAKa,UAASC,EAAAA,EACT,CAAA,EAAAd,KAAKa,WACLD,EAEP,CAEAG,WAAAA,IAAiCT,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,IACtBU,SAASC,WACZjB,KAAKa,UAAUI,EAAW,GAErC,CAEAC,UAAAA,GACElB,KAAKa,UAAY,EACnB,CAEAM,eAAAA,CAA6CC,GAC3C,MAAMC,EAAW,IAAIxB,EACfM,GACJiB,aAAI,EAAJA,EAAME,QAAO,CAACC,EAAKC,KACjBD,EAAIC,GAAOH,EAASG,GACbD,I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AI,IAAMtG,IAAQ+P,GAAK/P,EAAM+P,GAAKqxG,EAAM,CAC/C,CACF,CAQA1O,eAAAA,CACE/0G,EACA6yG,GAEA7yG,EAAG80G,UAAUjC,EAAiB6Q,WAAYpmH,KAAKkmH,SACjD,CAEA7b,cAAAA,GACE,OAAyB,IAAlBrqG,KAAKkmH,QACd,EAxDAnmH,EADWkmH,GAAQ,OAWL,YAAUlmH,EAXbkmH,GAAQ,WAbkC,CACrDC,SAAU,IAyB6BnmH,EAb5BkmH,GAee,mBAAA,CAAC,cA6C7B79G,GAAcM,SAASu9G"} \ No newline at end of file diff --git a/dist/index.mjs b/dist/index.mjs index e6d377fcc18..27a8e98cbde 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -405,7 +405,7 @@ class Cache { } const cache = new Cache(); -var version = "6.5.1"; +var version = "6.5.2"; // use this syntax so babel plugin see this import here const VERSION = version; @@ -2375,6 +2375,7 @@ class Color { * @returns {TRGBAColorSource} */ _tryParsingColor(color) { + color = color.toLowerCase(); if (color in ColorNameMap) { color = ColorNameMap[color]; } @@ -6844,8 +6845,8 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry { // for sure this ALIASING_LIMIT is slightly creating problem // in situation in which the cache canvas gets an upper limit // also objectScale contains already scaleX and scaleY - width: neededX + ALIASING_LIMIT, - height: neededY + ALIASING_LIMIT, + width: Math.ceil(neededX + ALIASING_LIMIT), + height: Math.ceil(neededY + ALIASING_LIMIT), zoomX: objectScale.x, zoomY: objectScale.y, x: neededX, @@ -6862,51 +6863,30 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry { _updateCacheCanvas() { const canvas = this._cacheCanvas, context = this._cacheContext, - dims = this._limitCacheSize(this._getCacheCanvasDimensions()), - minCacheSize = config.minCacheSideLimit, - width = dims.width, - height = dims.height, - zoomX = dims.zoomX, - zoomY = dims.zoomY, + { + width, + height, + zoomX, + zoomY, + x, + y + } = this._limitCacheSize(this._getCacheCanvasDimensions()), dimensionsChanged = width !== canvas.width || height !== canvas.height, zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY; if (!canvas || !context) { return false; } - let drawingWidth, - drawingHeight, - shouldRedraw = dimensionsChanged || zoomChanged, - additionalWidth = 0, - additionalHeight = 0, - shouldResizeCanvas = false; - if (dimensionsChanged) { - const canvasWidth = this._cacheCanvas.width, - canvasHeight = this._cacheCanvas.height, - sizeGrowing = width > canvasWidth || height > canvasHeight, - sizeShrinking = (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) && canvasWidth > minCacheSize && canvasHeight > minCacheSize; - shouldResizeCanvas = sizeGrowing || sizeShrinking; - if (sizeGrowing && !dims.capped && (width > minCacheSize || height > minCacheSize)) { - additionalWidth = width * 0.1; - additionalHeight = height * 0.1; - } - } - if (isTextObject(this) && this.path) { - shouldRedraw = true; - shouldResizeCanvas = true; - // IMHO in those lines we are using zoomX and zoomY not the this version. - additionalWidth += this.getHeightOfLine(0) * this.zoomX; - additionalHeight += this.getHeightOfLine(0) * this.zoomY; - } + const shouldRedraw = dimensionsChanged || zoomChanged; if (shouldRedraw) { - if (shouldResizeCanvas) { - canvas.width = Math.ceil(width + additionalWidth); - canvas.height = Math.ceil(height + additionalHeight); + if (width !== canvas.width || height !== canvas.height) { + canvas.width = width; + canvas.height = height; } else { context.setTransform(1, 0, 0, 1, 0, 0); context.clearRect(0, 0, canvas.width, canvas.height); } - drawingWidth = dims.x / 2; - drawingHeight = dims.y / 2; + const drawingWidth = x / 2; + const drawingHeight = y / 2; this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth; this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight; context.translate(this.cacheTranslationX, this.cacheTranslationY); @@ -15264,9 +15244,7 @@ class Canvas extends SelectableCanvas { * @private */ _resetTransformEventData() { - this._target = undefined; - this._pointer = undefined; - this._absolutePointer = undefined; + this._target = this._pointer = this._absolutePointer = undefined; } /** @@ -18470,8 +18448,6 @@ class StyledText extends FabricObject { * has no other properties, then it is also deleted. Finally, * if the line containing that character has no other characters * then it also is deleted. - * - * @param {string} property The property to compare between characters and text. */ cleanStyle(property) { if (!this.styles) { @@ -18517,7 +18493,6 @@ class StyledText extends FabricObject { graphemeCount += this._textLines[i].length; } if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) { - // @ts-expect-error conspiracy theory of TS this[property] = stylePropertyValue; this.removeStyle(property); } @@ -21510,10 +21485,8 @@ class ITextKeyBehavior extends ITextBehavior { } const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap; if (e.keyCode in keyMap) { - // @ts-expect-error legacy method calling pattern this[keyMap[e.keyCode]](e); } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) { - // @ts-expect-error legacy method calling pattern this[this.ctrlKeysMapDown[e.keyCode]](e); } else { return; @@ -21542,7 +21515,6 @@ class ITextKeyBehavior extends ITextBehavior { return; } if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) { - // @ts-expect-error legacy method calling pattern this[this.ctrlKeysMapUp[e.keyCode]](e); } else { return; @@ -22033,8 +22005,6 @@ class ITextClickBehavior extends ITextKeyBehavior { this.__lastLastClickTime = +new Date(); this.__lastPointer = {}; this.on('mousedown', this.onMouseDown); - - // @ts-expect-error in reality it is an IText instance this.draggableTextDelegate = new DraggableTextDelegate(this); super.initBehavior(); } @@ -23874,12 +23844,8 @@ class WebGLFilterBackend { cachedTexture = this.getCachedTexture(cacheKey, source); } const pipelineState = { - originalWidth: source.width || - // @ts-expect-error is this a bug? should this be naturalWidth? or is this the pipeline state? - source.originalWidth || 0, - originalHeight: source.height || - // @ts-expect-error is this a bug? should this be naturalHeight? or is this the pipeline state? - source.originalHeight || 0, + originalWidth: source.width || source.naturalWidth || 0, + originalHeight: source.height || source.naturalHeight || 0, sourceWidth: width, sourceHeight: height, destinationWidth: width, @@ -26037,65 +26003,70 @@ class BlendColor extends BaseFilter { } } = _ref; const source = new Color(this.color).getSource(); - const tr = source[0] * this.alpha; - const tg = source[1] * this.alpha; - const tb = source[2] * this.alpha; - const alpha1 = 1 - this.alpha; + const alpha = this.alpha; + const tr = source[0] * alpha; + const tg = source[1] * alpha; + const tb = source[2] * alpha; + const alpha1 = 1 - alpha; for (let i = 0; i < data.length; i += 4) { const r = data[i]; const g = data[i + 1]; const b = data[i + 2]; + let oR, oG, oB; switch (this.mode) { case 'multiply': - data[i] = r * tr / 255; - data[i + 1] = g * tg / 255; - data[i + 2] = b * tb / 255; + oR = r * tr / 255; + oG = g * tg / 255; + oB = b * tb / 255; break; case 'screen': - data[i] = 255 - (255 - r) * (255 - tr) / 255; - data[i + 1] = 255 - (255 - g) * (255 - tg) / 255; - data[i + 2] = 255 - (255 - b) * (255 - tb) / 255; + oR = 255 - (255 - r) * (255 - tr) / 255; + oG = 255 - (255 - g) * (255 - tg) / 255; + oB = 255 - (255 - b) * (255 - tb) / 255; break; case 'add': - data[i] = r + tr; - data[i + 1] = g + tg; - data[i + 2] = b + tb; + oR = r + tr; + oG = g + tg; + oB = b + tb; break; case 'difference': - data[i] = Math.abs(r - tr); - data[i + 1] = Math.abs(g - tg); - data[i + 2] = Math.abs(b - tb); + oR = Math.abs(r - tr); + oG = Math.abs(g - tg); + oB = Math.abs(b - tb); break; case 'subtract': - data[i] = r - tr; - data[i + 1] = g - tg; - data[i + 2] = b - tb; + oR = r - tr; + oG = g - tg; + oB = b - tb; break; case 'darken': - data[i] = Math.min(r, tr); - data[i + 1] = Math.min(g, tg); - data[i + 2] = Math.min(b, tb); + oR = Math.min(r, tr); + oG = Math.min(g, tg); + oB = Math.min(b, tb); break; case 'lighten': - data[i] = Math.max(r, tr); - data[i + 1] = Math.max(g, tg); - data[i + 2] = Math.max(b, tb); + oR = Math.max(r, tr); + oG = Math.max(g, tg); + oB = Math.max(b, tb); break; case 'overlay': - data[i] = tr < 128 ? 2 * r * tr / 255 : 255 - 2 * (255 - r) * (255 - tr) / 255; - data[i + 1] = tg < 128 ? 2 * g * tg / 255 : 255 - 2 * (255 - g) * (255 - tg) / 255; - data[i + 2] = tb < 128 ? 2 * b * tb / 255 : 255 - 2 * (255 - b) * (255 - tb) / 255; + oR = tr < 128 ? 2 * r * tr / 255 : 255 - 2 * (255 - r) * (255 - tr) / 255; + oG = tg < 128 ? 2 * g * tg / 255 : 255 - 2 * (255 - g) * (255 - tg) / 255; + oB = tb < 128 ? 2 * b * tb / 255 : 255 - 2 * (255 - b) * (255 - tb) / 255; break; case 'exclusion': - data[i] = tr + r - 2 * tr * r / 255; - data[i + 1] = tg + g - 2 * tg * g / 255; - data[i + 2] = tb + b - 2 * tb * b / 255; + oR = tr + r - 2 * tr * r / 255; + oG = tg + g - 2 * tg * g / 255; + oB = tb + b - 2 * tb * b / 255; break; case 'tint': - data[i] = tr + r * alpha1; - data[i + 1] = tg + g * alpha1; - data[i + 2] = tb + b * alpha1; + oR = tr + r * alpha1; + oG = tg + g * alpha1; + oB = tb + b * alpha1; } + data[i] = oR; + data[i + 1] = oG; + data[i + 2] = oB; } } @@ -26504,9 +26475,9 @@ class Brightness extends BaseFilter { } = _ref; const brightness = Math.round(this.brightness * 255); for (let i = 0; i < data.length; i += 4) { - data[i] = data[i] + brightness; - data[i + 1] = data[i + 1] + brightness; - data[i + 2] = data[i + 2] + brightness; + data[i] += brightness; + data[i + 1] += brightness; + data[i + 2] += brightness; } } isNeutralState() { @@ -26578,16 +26549,15 @@ class ColorMatrix extends BaseFilter { const r = data[i]; const g = data[i + 1]; const b = data[i + 2]; - if (colorsOnly) { - data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255; - data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255; - data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255; - } else { + data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255; + data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255; + data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255; + if (!colorsOnly) { const a = data[i + 3]; - data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255; - data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255; - data[i + 2] = r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255; - data[i + 3] = r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255; + data[i] += a * m[3]; + data[i + 1] += a * m[8]; + data[i + 2] += a * m[13]; + data[i + 3] += a * m[18]; } } } @@ -26633,7 +26603,6 @@ classRegistry.setClass(ColorMatrix); function createColorMatrixFilter(key, matrix) { var _Class; const newClass = (_Class = class newClass extends ColorMatrix { - //@ts-expect-error TS wants matrix to be exported. toObject() { return { type: this.type, @@ -26684,7 +26653,6 @@ class Composed extends BaseFilter { * Serialize this filter into JSON. * @returns {Object} A JSON representation of this filter. */ - //@ts-expect-error TS doesn't like this toObject toObject() { return { type: this.type, @@ -27064,20 +27032,21 @@ class Grayscale extends BaseFilter { } } = _ref; for (let i = 0, value; i < data.length; i += 4) { + const r = data[i]; + const g = data[i + 1]; + const b = data[i + 2]; switch (this.mode) { case 'average': - value = (data[i] + data[i + 1] + data[i + 2]) / 3; + value = (r + g + b) / 3; break; case 'lightness': - value = (Math.min(data[i], data[i + 1], data[i + 2]) + Math.max(data[i], data[i + 1], data[i + 2])) / 2; + value = (Math.min(r, g, b) + Math.max(r, g, b)) / 2; break; case 'luminosity': - value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2]; + value = 0.21 * r + 0.72 * g + 0.07 * b; break; } - data[i] = value; - data[i + 1] = value; - data[i + 2] = value; + data[i + 2] = data[i + 1] = data[i] = value; } } getCacheKey() { @@ -27112,9 +27081,9 @@ _defineProperty(Grayscale, "defaults", grayscaleDefaultValues); _defineProperty(Grayscale, "uniformLocations", ['uMode']); classRegistry.setClass(Grayscale); -const hueRotationDefaultValues = { +const hueRotationDefaultValues = _objectSpread2(_objectSpread2({}, colorMatrixDefaultValues), {}, { rotation: 0 -}; +}); /** * HueRotation filter class @@ -27133,16 +27102,7 @@ class HueRotation extends ColorMatrix { aThird = 1 / 3, aThirdSqtSin = Math.sqrt(aThird) * sine, OneMinusCos = 1 - cosine; - this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]; - this.matrix[0] = cosine + OneMinusCos / 3; - this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin; - this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin; - this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin; - this.matrix[6] = cosine + aThird * OneMinusCos; - this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin; - this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin; - this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin; - this.matrix[12] = cosine + aThird * OneMinusCos; + this.matrix = [cosine + OneMinusCos / 3, aThird * OneMinusCos - aThirdSqtSin, aThird * OneMinusCos + aThirdSqtSin, 0, 0, aThird * OneMinusCos + aThirdSqtSin, cosine + aThird * OneMinusCos, aThird * OneMinusCos - aThirdSqtSin, 0, 0, aThird * OneMinusCos - aThirdSqtSin, aThird * OneMinusCos + aThirdSqtSin, cosine + aThird * OneMinusCos, 0, 0, 0, 0, 0, 1, 0]; } isNeutralState() { return this.rotation === 0; @@ -27151,8 +27111,6 @@ class HueRotation extends ColorMatrix { this.calculateMatrix(); super.applyTo(options); } - - //@ts-expect-error TS and classes with different methods toObject() { return { type: this.type, @@ -27922,10 +27880,13 @@ class Saturation extends BaseFilter { } = _ref; const adjust = -this.saturation; for (let i = 0; i < data.length; i += 4) { - const max = Math.max(data[i], data[i + 1], data[i + 2]); - data[i] += max !== data[i] ? (max - data[i]) * adjust : 0; - data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0; - data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0; + const r = data[i]; + const g = data[i + 1]; + const b = data[i + 2]; + const max = Math.max(r, g, b); + data[i] += max !== r ? (max - r) * adjust : 0; + data[i + 1] += max !== g ? (max - g) * adjust : 0; + data[i + 2] += max !== b ? (max - b) * adjust : 0; } } @@ -27989,12 +27950,15 @@ class Vibrance extends BaseFilter { } = _ref; const adjust = -this.vibrance; for (let i = 0; i < data.length; i += 4) { - const max = Math.max(data[i], data[i + 1], data[i + 2]); - const avg = (data[i] + data[i + 1] + data[i + 2]) / 3; + const r = data[i]; + const g = data[i + 1]; + const b = data[i + 2]; + const max = Math.max(r, g, b); + const avg = (r + g + b) / 3; const amt = Math.abs(max - avg) * 2 / 255 * adjust; - data[i] += max !== data[i] ? (max - data[i]) * amt : 0; - data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0; - data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0; + data[i] += max !== r ? (max - r) * amt : 0; + data[i + 1] += max !== g ? (max - g) * amt : 0; + data[i + 2] += max !== b ? (max - b) * amt : 0; } } diff --git a/dist/index.mjs.map b/dist/index.mjs.map index b588670e0af..b039bf35af8 100644 --- a/dist/index.mjs.map +++ b/dist/index.mjs.map @@ -1 +1 @@ -{"version":3,"file":"index.mjs","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/constants.ts","../src/color/util.ts","../src/color/Color.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/rotatePoint.ts","../src/util/internals/findRight.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/elementMatchesRule.ts","../src/parser/getGlobalStylesForElement.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleObject.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/CanvasOptions.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/brushes/CircleBrush.ts","../src/brushes/SprayBrush.ts","../src/brushes/PatternBrush.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/parseUseDirectives.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/shaders/blur.ts","../src/filters/Blur.ts","../src/filters/shaders/brightness.ts","../src/filters/Brightness.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/shaders/constrast.ts","../src/filters/Contrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/shaders/invert.ts","../src/filters/Invert.ts","../src/filters/shaders/noise.ts","../src/filters/Noise.ts","../src/filters/shaders/pixelate.ts","../src/filters/Pixelate.ts","../src/filters/shaders/removeColor.ts","../src/filters/RemoveColor.ts","../src/filters/Resize.ts","../src/filters/shaders/saturation.ts","../src/filters/Saturation.ts","../src/filters/shaders/vibrance.ts","../src/filters/Vibrance.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport {\n isFiller,\n isSerializableFiller,\n isTextObject,\n} from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: neededX + ALIASING_LIMIT,\n height: neededY + ALIASING_LIMIT,\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n minCacheSize = config.minCacheSideLimit,\n width = dims.width,\n height = dims.height,\n zoomX = dims.zoomX,\n zoomY = dims.zoomY,\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n let drawingWidth,\n drawingHeight,\n shouldRedraw = dimensionsChanged || zoomChanged,\n additionalWidth = 0,\n additionalHeight = 0,\n shouldResizeCanvas = false;\n\n if (dimensionsChanged) {\n const canvasWidth = (this._cacheCanvas as HTMLCanvasElement).width,\n canvasHeight = (this._cacheCanvas as HTMLCanvasElement).height,\n sizeGrowing = width > canvasWidth || height > canvasHeight,\n sizeShrinking =\n (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) &&\n canvasWidth > minCacheSize &&\n canvasHeight > minCacheSize;\n shouldResizeCanvas = sizeGrowing || sizeShrinking;\n if (\n sizeGrowing &&\n !dims.capped &&\n (width > minCacheSize || height > minCacheSize)\n ) {\n additionalWidth = width * 0.1;\n additionalHeight = height * 0.1;\n }\n }\n if (isTextObject(this) && this.path) {\n shouldRedraw = true;\n shouldResizeCanvas = true;\n // IMHO in those lines we are using zoomX and zoomY not the this version.\n additionalWidth += this.getHeightOfLine(0) * this.zoomX!;\n additionalHeight += this.getHeightOfLine(0) * this.zoomY!;\n }\n if (shouldRedraw) {\n if (shouldResizeCanvas) {\n canvas.width = Math.ceil(width + additionalWidth);\n canvas.height = Math.ceil(height + additionalHeight);\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n drawingWidth = dims.x / 2;\n drawingHeight = dims.y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = undefined;\n this._pointer = undefined;\n this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n *\n * @param {string} property The property to compare between characters and text.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n // @ts-expect-error conspiracy theory of TS\n this[property as keyof this] = stylePropertyValue;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n // @ts-expect-error readonly\n ...pick(this, (this.constructor as typeof StyledText)._styleProperties),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n // @ts-expect-error legacy method calling pattern\n this[keyMap[e.keyCode]](e);\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapDown[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapUp[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\n\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n // @ts-expect-error in reality it is an IText instance\n this.draggableTextDelegate = new DraggableTextDelegate(this);\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n // @ts-expect-error is this a bug? should this be naturalWidth? or is this the pipeline state?\n (source as HTMLImageElement).originalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n // @ts-expect-error is this a bug? should this be naturalHeight? or is this the pipeline state?\n (source as HTMLImageElement).originalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const tr = source[0] * this.alpha;\n const tg = source[1] * this.alpha;\n const tb = source[2] * this.alpha;\n const alpha1 = 1 - this.alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n break;\n case 'screen':\n data[i] = 255 - ((255 - r) * (255 - tr)) / 255;\n data[i + 1] = 255 - ((255 - g) * (255 - tg)) / 255;\n data[i + 2] = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n data[i] = r + tr;\n data[i + 1] = g + tg;\n data[i + 2] = b + tb;\n break;\n case 'difference':\n data[i] = Math.abs(r - tr);\n data[i + 1] = Math.abs(g - tg);\n data[i + 2] = Math.abs(b - tb);\n break;\n case 'subtract':\n data[i] = r - tr;\n data[i + 1] = g - tg;\n data[i + 2] = b - tb;\n break;\n case 'darken':\n data[i] = Math.min(r, tr);\n data[i + 1] = Math.min(g, tg);\n data[i + 2] = Math.min(b, tb);\n break;\n case 'lighten':\n data[i] = Math.max(r, tr);\n data[i + 1] = Math.max(g, tg);\n data[i + 2] = Math.max(b, tb);\n break;\n case 'overlay':\n data[i] =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n data[i + 1] =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n data[i + 2] =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n data[i] = tr + r - (2 * tr * r) / 255;\n data[i + 1] = tg + g - (2 * tg * g) / 255;\n data[i + 2] = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n data[i] = tr + r * alpha1;\n data[i + 1] = tg + g * alpha1;\n data[i + 2] = tb + b * alpha1;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = data[i] + brightness;\n data[i + 1] = data[i + 1] + brightness;\n data[i + 2] = data[i + 2] + brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\ntype ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n if (colorsOnly) {\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n } else {\n const a = data[i + 3];\n data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255;\n data[i + 2] =\n r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255;\n data[i + 3] =\n r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject() {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n //@ts-expect-error TS wants matrix to be exported.\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<'Composed', ComposedOwnProps> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n //@ts-expect-error TS doesn't like this toObject\n toObject(): {\n type: 'Composed';\n subFilters: ReturnType['toObject']>[];\n } {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n switch (this.mode) {\n case 'average':\n value = (data[i] + data[i + 1] + data[i + 2]) / 3;\n break;\n case 'lightness':\n value =\n (Math.min(data[i], data[i + 1], data[i + 2]) +\n Math.max(data[i], data[i + 1], data[i + 2])) /\n 2;\n break;\n case 'luminosity':\n value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2];\n break;\n }\n\n data[i] = value;\n data[i + 1] = value;\n data[i + 2] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport { ColorMatrix } from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];\n this.matrix[0] = cosine + OneMinusCos / 3;\n this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[6] = cosine + aThird * OneMinusCos;\n this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[12] = cosine + aThird * OneMinusCos;\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n //@ts-expect-error TS and classes with different methods\n toObject(): { type: 'HueRotation'; rotation: number } {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentShader = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n data[i] += max !== data[i] ? (max - data[i]) * adjust : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n const avg = (data[i] + data[i + 1] + data[i + 2]) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== data[i] ? (max - data[i]) * amt : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n"],"names":["BaseConfiguration","constructor","_defineProperty","window","devicePixelRatio","Configuration","config","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","fontFamilys","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","env","setEnv","value","getBrowserEnv","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","Cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","cache","VERSION","version","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","ALIASING_LIMIT","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","ClassRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","classRegistry","AnimationRegistry","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","runningAnimations","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","onceHandler","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","idx","cos","angle","angleSlice","abs","sin","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","rotated","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","element","createElement","createImage","copyCanvasElement","_newCanvas$getContext","newCanvas","createCanvasElementFor","drawImage","toDataURL","canvasEl","format","quality","isHTMLCanvas","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","reRGBa","reHSLa","reHex","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","fullHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherAlpha","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","match1degrees","parseAngletoDegrees","fromHex","isShortNotation","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","getSvgAttributes","commonAttributes","parseUnit","fontSize","unit","exec","dpi","DPI","parseAlign","align","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","inlineStyle","colorValue","opacityValue","toLive","opacity","createSVGRect","svgColor","w","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","_renderText","isPath","_renderPathCommands","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","getElementOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","shouldInvert","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getTouchInfo","event","touchProp","changedTouches","getPointer","scroll","_evt","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","removeTransformFromObject","inverted","finalTransform","calcOwnMatrix","applyTransformToObject","addTransformToObject","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","to","sendPointToPlane","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","getActionFromCorner","alreadySelected","corner","control","controls","getActionName","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","getTotalAngle","cornerAngle","normalizePoint","getRelativeCenterPoint","translateToGivenOrigin","p2","getLocalPoint","padding","localPoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","svgValidTagNames","svgViewBoxElements","svgInvalidAncestors","svgValidParents","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","shadowDefaultValues","blur","affectStroke","nonScaling","Shadow","parseShadow","shadowStr","replace","BLUR_BOX","fBoxX","fBoxY","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","centeredRotation","centeredScaling","dirty","interactiveObjectDefaultValues","noScaleCache","lockMovementX","lockMovementY","lockRotation","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","cornerSize","touchCornerSize","transparentCorners","cornerColor","cornerStrokeColor","cornerStyle","cornerDashArray","hasControls","borderColor","borderDashArray","borderOpacityWhenMoving","borderScaleFactor","hasBorders","selectionBackgroundColor","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","normalize","c","asin","elastic","defaultEasing","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInElastic","normA","normS","normP","easeOutElastic","normC","easeInOutElastic","easeInBack","easeOutBack","easeInOutBack","easeOutBounce","easeInBounce","easeInOutBounce","easeInQuad","easeOutQuad","easeInOutQuad","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","isArrayAnimation","animate","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","AT","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersection","intersectsWithObject","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","allPointsAreOutside","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","noSkew","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","minCacheSize","dimensionsChanged","zoomChanged","drawingWidth","drawingHeight","shouldRedraw","additionalWidth","additionalHeight","shouldResizeCanvas","canvasWidth","canvasHeight","sizeGrowing","sizeShrinking","getHeightOfLine","ceil","setTransform","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","ImageClass","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","hasStaticDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeObjectWidth","strokePadding","oldWidth","newWidth","changeWidth","renderCircleControl","styleOverride","xSize","sizeX","ySize","sizeY","myLeft","myTop","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","rotationStyleHandler","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","rotationWithSnapping","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","forbidScaling","signX","signY","gestureScale","distance","original","originalDistance","oldScaleX","oldScaleY","scaleObjectFromCorner","scaleObjectX","scaleObjectY","scalingEqually","scalingX","scalingY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewObject","axis","skewingSide","skewKey","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewHandler","originKey","lockSkewingKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingDirection","finalHandler","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","fn","_activeObject","wh","strokeBorders","_drawBorders","drawControlsConnectingLines","_renderControls","styleOptions","shouldDrawBorders","shouldDrawControls","isMoving","drawBorders","forActiveSelection","shouldStroke","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","isTransparent","tolerance","getImageData","alphaChannel","rotatePoint","findIndexRight","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","radiusOnAxisX","radiusOnAxisY","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","cloneStyles","newObj","keyInner","capitalize","string","firstLetterOnly","charAt","escapeXml","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","next","prev","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","doesSomeParentMatch","selectors","parentMatching","parentElement","elementMatchesRule","firstMatching","getGlobalStylesForElement","cssRules","rule","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleObject","parseStyleString","chunk","parseStyleAttribute","colorAttributesMap","setStrokeFillOpacity","attributes","colorAttr","parseAttributes","parentFontSize","ownAttributes","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","rectDefaultValues","rx","ry","RECT_PROPS","Rect","_initRxRy","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","LAYOUT_TYPE_OBJECT_MODIFIED","LAYOUT_TYPE_OBJECT_MODIFYING","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxLeftTop","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","layoutObjects","_context$x","_context$y","layoutObject","_","bubblingContext","NoopLayoutManager","groupDefaultValues","subTargetCheck","interactive","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","groupSVGElements","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","rePathCommand","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","cp1X","cp1Y","cp2X","cp2Y","arcToSegments","large","sweep","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","calcVectorAngle","dtheta","segments","mDelta","th3","ux","uy","vx","vy","ta","tb","CB1","CB2","CB3","CB4","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","tx","ty","segsNorm","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","c3","c4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","totalLength","tempInfo","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","multSignX","multSignY","manyPoints","midPoint","transformPath","pathOffset","pathSegment","newSegment","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","joinPath","pathData","setStyle","elementStyle","setProperty","mergeClipPaths","_b$group","getRandomInt","random","request","xhr","XMLHttpRequest","removeListener","ontimeout","onreadystatechange","readyState","open","send","_assignTransformMatrixProps","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","cropX","cropY","offsetLeft","offsetTop","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","canvasDefaults","centeredKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","_drawSelection","renderTop","setTargetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","_control$getActionHan","getScenePoint","altKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","minX","minY","maxX","maxY","findTarget","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","layoutProps","originalValues","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_fireOverOutEvents","_transformObject","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","klass","newActiveSelection","point1","point2","collectedObjects","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","convertPercentUnitsToValues","valuesToConvert","finalValue","propValue","getValue","parseLinearCoords","parseRadialCoords","parseCoords","Gradient","addColorStop","colorStop","preTransform","sort","needsSwap","minRadius","maxRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","isEmptySVGPath","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","lastPoint","cDistance","adjustedDistance","newPoints","decimate","CIRCLE_PROPS","circleDefaultValues","startAngle","endAngle","Circle","setRadius","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","otherParsedAttributes","CircleBrush","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","getUniqueRects","rects","uniqueRects","uniqueRectsArray","SprayBrush","sprayChunks","sprayChunk","addSprayChunk","renderChunck","chunck","rect","optimizeOverlapping","sprayChunck","density","dotWidthVariance","dotWidth","randomOpacity","PatternBrush","getPatternSrc","dotDistance","patternCanvas","patternCtx","getPattern","pattern","topLeft","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","triangleDefaultValues","Triangle","widthBy2","heightBy2","ellipseDefaultValues","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","stylesCount","letterCount","stylePropertyValue","allStyleObjectPropertiesMatch","graphemeCount","styleObject","stylePropertyHasBeenSet","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","TextSVGExportMixin","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","textBgRects","textSpans","noShadow","textDecoration","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_getLineLeftOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","isJustify","actualStyle","nextStyle","charsToRender","charBox","boxWidth","timeToRender","__charBounds","kernedWidth","leftOffset","heightOfLine","boxStart","currentColor","lastColor","getValueOfPropertyAt","_getSVGLineTopOffset","lineTopOffset","lastHeight","useWhiteSpace","decoration","measuringContext","getMeasuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","_getLeftOffset","_getTopOffset","lineLeftOffset","drawStart","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","shortCut","isLtr","currentDirection","drawingLeft","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","lastDecoration","lastFill","currentDecoration","currentFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","restOfOptions","textContent","textHeightScaleFactor","lineHeightDiff","scaledDiff","textHeight","offX","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","selectionPosition","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","graphemeEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","charDiff","removeFrom","removeTo","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","widthBeforeCursor","bound","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","textAfterCursor","getUpCursorOffset","textBeforeCursor","widthOfCharsOnLine","indexOnLine","charWidth","foundMatch","leftEdge","rightEdge","offsetFromLeftEdge","offsetFromRightEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","protectedDefaultValues","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderCursor","renderSelection","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","textboxDefaultValues","minWidth","dynamicMinWidth","_wordJoiners","splitByGrapheme","Textbox","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","isWrapping","nextLineIndex","nextOffset","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","activeSelectionDefaultValues","multiSelectionStacking","ActiveSelection","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","imageData","originalImageData","pipelineState","originalEl","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","glOptions","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","dWidth","dHeight","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","strict","setFilterBackend","backend","imageDefaultValues","srcFromAttribute","minimumScaleTrigger","imageSmoothing","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","getSvgSrc","origFill","filtered","setSrc","minimumScale","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","goodViewbox","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","hasInvalidAncestor","getMultipleNodes","nodeNames","nodeArray","nodeList","getElementsByTagNameNS","parseUseDirectives","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","cloneNode","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","tagArray","getGradientDefs","elList","gradientDefs","getCSSRules","allRules","styleContents","ruleObj","declaration","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","parseSVGDocument","descendants","localClipPaths","elementParser","loadSVGFromString","parser","DOMParser","parseFromString","loadSVGFromURL","xml","responseXML","parsedDoc","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","newAnchorPointInParentPlane","createPolyActionHandler","createPolyControls","calcPathPointPosition","pathObject","commandIndex","movePathPoint","anchorCommand","pathPositionHandler","pathActionHandler","indexFromPrevCommand","previousCommandType","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","createPathControls","isWebGLPipelineState","isPutImageFaster","sourceCanvas","ArrayBuffer","testContext","testPipelineState","performance","now","drawImageTime","putImageDataTime","highPsourceCode","identityFragmentShader","vertexSource","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","filterOptions","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","blendColorDefaultValues","mode","BlendColor","tg","alpha1","uniform4fv","uColor","mask","blendImageDefaultValues","BlendImage","image","TEXTURE1","calculateMatrix","resources","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","enlivedImage","blurDefaultValues","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","brightnessDefaultValues","brightness","Brightness","uBrightness","colorMatrixDefaultValues","colorsOnly","ColorMatrix","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","contrastDefaultValues","contrast","Contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","convoluteDefaultValues","opaque","Convolute","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","gammaDefaultValues","gamma","Gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","grayscaleDefaultValues","Grayscale","uMode","hueRotationDefaultValues","rotation","HueRotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","invertDefaultValues","invert","Invert","uInvert","uAlpha","noiseDefaultValues","noise","Noise","rand","uNoise","uSeed","pixelateDefaultValues","blocksize","Pixelate","_i","_j","uBlocksize","removeColorDefaultValues","useAlpha","RemoveColor","lowC","highC","uLow","uHigh","resizeDefaultValues","resizeType","lanczosLobes","Resize","uTaps","taps","getFilterWindow","tempScale","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","process","u","weight","fX","fY","ratioX","icenter","ratioY","range2X","cacheLanc","range2Y","lanczos","rcpRatioX","rcpRatioY","srcData","destData","destImg","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","saturationDefaultValues","saturation","Saturation","adjust","uSaturation","vibranceDefaultValues","vibrance","Vibrance","amt","uVibrance"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA,iBAAiB,CAAC;EAAAC,WAAA,GAAA;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbEC,IAAAA,eAAA,oCAc4B,CAAC,CAAA,CAAA;AAE7B;AACF;AACA;AAFEA,IAAAA,eAAA,cAGM,EAAE,CAAA,CAAA;AAER;AACF;AACA;AACA;IAHEA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAKE,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACC,gBAAgB,GAAG,CAAC,CAAA,CAAA;AAAE;AAE/D;AACF;AACA;AACA;AACA;AACA;AALEF,IAAAA,eAAA,6BAMqB,OAAO,CAAA,CAAA;AAE5B;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMoB,IAAI,CAAA,CAAA;AAExB;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMoB,GAAG,CAAA,CAAA;AAEvB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,gCAQwB,KAAK,CAAA,CAAA;AAE7B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,4BAQoB,IAAI,CAAA,CAAA;AAExB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATEA,IAAAA,eAAA,sBAUc,IAAI,CAAA,CAAA;AAElB;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,8BAOsB,KAAK,CAAA,CAAA;AAE3B;AACF;AACA;AACA;AACA;AACA;AACA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,EAAE,MAAM;AACdC,EAAAA,WAAW,EAAE,SAAA;AACf,CAAC;;ACzJD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,MACpB,kJAAkJ,CAAA;;AAEpJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,MACpB,kKAAkK,CAAA;;AAEpK;AACA;AACA;AACO,MAAMC,KAAK,GAAGA,MAAM,2CAA2C;;AC/GtE;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CAACvU,CAAS,EAAEwU,CAAS,EAAE3V,CAAS,KAAa;EAClE,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;EACA,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;AACA,EAAA,IAAIA,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IACb,OAAOmB,CAAC,GAAG,CAACwU,CAAC,GAAGxU,CAAC,IAAI,CAAC,GAAGnB,CAAC,CAAA;AAC5B,GAAA;AACA,EAAA,IAAIA,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACb,IAAA,OAAO2V,CAAC,CAAA;AAC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CC,EAAAA,kBAAkB,EAAE,EAAE;AACtBC,EAAAA,oBAAoB,EAAE,0BAA0B;AAChDC,EAAAA,kBAAkB,EAAE,CAAC;AACrBC,EAAAA,uBAAuB,EAAE,KAAK;AAE9B5iC,EAAAA,WAAW,EAAE,MAAM;AACnBC,EAAAA,UAAU,EAAE,MAAM;AAClB4iC,EAAAA,aAAa,EAAE,SAAS;AACxBC,EAAAA,iBAAiB,EAAE,WAAW;AAC9BC,EAAAA,gBAAgB,EAAE,aAAa;AAE/BjjC,EAAAA,kBAAkB,EAAE,KAAK;AACzBkjC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,cAAc,EAAE,KAAK;AAErBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,cAAc,EAAE,KAAK;AACrBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,mBAAmB,EAAE,KAAK;AAE1B3B,EAAAA,cAAc,EAAE,kBAAkB;AAElC5N,EAAAA,sBAAsB,EAAE,KAAA;AAC1B,CAAC;;ACnPD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMwP,gBAAgB,SACnB56C,YAAY,CAEtB;EAAAjvB,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAAO,SAAA,CAAA,CAAA;AAGE;AAQA;AAUA;AASA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;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"index.mjs","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/constants.ts","../src/color/util.ts","../src/color/Color.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/rotatePoint.ts","../src/util/internals/findRight.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/elementMatchesRule.ts","../src/parser/getGlobalStylesForElement.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleObject.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/CanvasOptions.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/brushes/CircleBrush.ts","../src/brushes/SprayBrush.ts","../src/brushes/PatternBrush.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/parseUseDirectives.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/shaders/blur.ts","../src/filters/Blur.ts","../src/filters/shaders/brightness.ts","../src/filters/Brightness.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/shaders/constrast.ts","../src/filters/Contrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/shaders/invert.ts","../src/filters/Invert.ts","../src/filters/shaders/noise.ts","../src/filters/Noise.ts","../src/filters/shaders/pixelate.ts","../src/filters/Pixelate.ts","../src/filters/shaders/removeColor.ts","../src/filters/RemoveColor.ts","../src/filters/Resize.ts","../src/filters/shaders/saturation.ts","../src/filters/Saturation.ts","../src/filters/shaders/vibrance.ts","../src/filters/Vibrance.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n color = color.toLowerCase();\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport { isFiller, isSerializableFiller } from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: Math.ceil(neededX + ALIASING_LIMIT),\n height: Math.ceil(neededY + ALIASING_LIMIT),\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n { width, height, zoomX, zoomY, x, y } = this._limitCacheSize(\n this._getCacheCanvasDimensions(),\n ),\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n const shouldRedraw = dimensionsChanged || zoomChanged;\n\n if (shouldRedraw) {\n if (width !== canvas.width || height !== canvas.height) {\n canvas.width = width;\n canvas.height = height;\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n const drawingWidth = x / 2;\n const drawingHeight = y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = this._pointer = this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n this[property as keyof this] = stylePropertyValue as any;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n ...pick(\n this,\n (this.constructor as typeof StyledText)\n ._styleProperties as (keyof this)[],\n ),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n (this[keyMap[e.keyCode] as keyof this] as (arg: KeyboardEvent) => void)(\n e,\n );\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapDown[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapUp[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport type { IText } from './IText';\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n this.draggableTextDelegate = new DraggableTextDelegate(\n this as unknown as IText,\n );\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n (source as HTMLImageElement).naturalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n (source as HTMLImageElement).naturalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n SerializedProps extends Record = OwnProps,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & SerializedProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof SerializedProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as SerializedProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const alpha = this.alpha;\n const tr = source[0] * alpha;\n const tg = source[1] * alpha;\n const tb = source[2] * alpha;\n const alpha1 = 1 - alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n let oR, oG, oB;\n switch (this.mode) {\n case 'multiply':\n oR = (r * tr) / 255;\n oG = (g * tg) / 255;\n oB = (b * tb) / 255;\n break;\n case 'screen':\n oR = 255 - ((255 - r) * (255 - tr)) / 255;\n oG = 255 - ((255 - g) * (255 - tg)) / 255;\n oB = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n oR = r + tr;\n oG = g + tg;\n oB = b + tb;\n break;\n case 'difference':\n oR = Math.abs(r - tr);\n oG = Math.abs(g - tg);\n oB = Math.abs(b - tb);\n break;\n case 'subtract':\n oR = r - tr;\n oG = g - tg;\n oB = b - tb;\n break;\n case 'darken':\n oR = Math.min(r, tr);\n oG = Math.min(g, tg);\n oB = Math.min(b, tb);\n break;\n case 'lighten':\n oR = Math.max(r, tr);\n oG = Math.max(g, tg);\n oB = Math.max(b, tb);\n break;\n case 'overlay':\n oR =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n oG =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n oB =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n oR = tr + r - (2 * tr * r) / 255;\n oG = tg + g - (2 * tg * g) / 255;\n oB = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n oR = tr + r * alpha1;\n oG = tg + g * alpha1;\n oB = tb + b * alpha1;\n }\n data[i] = oR;\n data[i + 1] = oG;\n data[i + 2] = oB;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] += brightness;\n data[i + 1] += brightness;\n data[i + 2] += brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\nexport type ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n SerializedProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n if (!colorsOnly) {\n const a = data[i + 3];\n data[i] += a * m[3];\n data[i + 1] += a * m[8];\n data[i + 2] += a * m[13];\n data[i + 3] += a * m[18];\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject(): { type: Name } & SerializedProps {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix<\n typeof key,\n FixedFiltersOwnProps,\n FixedFiltersOwnProps\n > {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\ntype ComposedSerializedProps = {\n subFilters: Record[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<\n 'Composed',\n ComposedOwnProps,\n ComposedSerializedProps\n> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n toObject() {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n switch (this.mode) {\n case 'average':\n value = (r + g + b) / 3;\n break;\n case 'lightness':\n value = (Math.min(r, g, b) + Math.max(r, g, b)) / 2;\n break;\n case 'luminosity':\n value = 0.21 * r + 0.72 * g + 0.07 * b;\n break;\n }\n\n data[i + 2] = data[i + 1] = data[i] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport {\n ColorMatrix,\n type ColorMatrixOwnProps,\n colorMatrixDefaultValues,\n} from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = ColorMatrixOwnProps & {\n rotation: number;\n};\n\nexport type HueRotationSerializedProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n ...colorMatrixDefaultValues,\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps,\n HueRotationSerializedProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [\n cosine + OneMinusCos / 3,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n aThird * OneMinusCos - aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n 0,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n ];\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n toObject() {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentShader = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n data[i] += max !== r ? (max - r) * adjust : 0;\n data[i + 1] += max !== g ? (max - g) * adjust : 0;\n data[i + 2] += max !== b ? (max - b) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n const avg = (r + g + b) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== r ? (max - r) * amt : 0;\n data[i + 1] += max !== g ? (max - g) * amt : 0;\n data[i + 2] += max !== b ? (max - b) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n"],"names":["BaseConfiguration","constructor","_defineProperty","window","devicePixelRatio","Configuration","config","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","fontFamilys","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","env","setEnv","value","getBrowserEnv","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","Cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","cache","VERSION","version","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","ALIASING_LIMIT","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","ClassRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","classRegistry","AnimationRegistry","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","runningAnimations","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","onceHandler","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","idx","cos","angle","angleSlice","abs","sin","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","rotated","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","element","createElement","createImage","copyCanvasElement","_newCanvas$getContext","newCanvas","createCanvasElementFor","drawImage","toDataURL","canvasEl","format","quality","isHTMLCanvas","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","reRGBa","reHSLa","reHex","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","fullHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherAlpha","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","match1degrees","parseAngletoDegrees","fromHex","isShortNotation","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","getSvgAttributes","commonAttributes","parseUnit","fontSize","unit","exec","dpi","DPI","parseAlign","align","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","inlineStyle","colorValue","opacityValue","toLive","opacity","createSVGRect","svgColor","w","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","_renderText","isPath","_renderPathCommands","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","getElementOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","shouldInvert","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getTouchInfo","event","touchProp","changedTouches","getPointer","scroll","_evt","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","removeTransformFromObject","inverted","finalTransform","calcOwnMatrix","applyTransformToObject","addTransformToObject","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","to","sendPointToPlane","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","getActionFromCorner","alreadySelected","corner","control","controls","getActionName","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","getTotalAngle","cornerAngle","normalizePoint","getRelativeCenterPoint","translateToGivenOrigin","p2","getLocalPoint","padding","localPoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","svgValidTagNames","svgViewBoxElements","svgInvalidAncestors","svgValidParents","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","shadowDefaultValues","blur","affectStroke","nonScaling","Shadow","parseShadow","shadowStr","replace","BLUR_BOX","fBoxX","fBoxY","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","centeredRotation","centeredScaling","dirty","interactiveObjectDefaultValues","noScaleCache","lockMovementX","lockMovementY","lockRotation","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","cornerSize","touchCornerSize","transparentCorners","cornerColor","cornerStrokeColor","cornerStyle","cornerDashArray","hasControls","borderColor","borderDashArray","borderOpacityWhenMoving","borderScaleFactor","hasBorders","selectionBackgroundColor","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","normalize","c","asin","elastic","defaultEasing","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInElastic","normA","normS","normP","easeOutElastic","normC","easeInOutElastic","easeInBack","easeOutBack","easeInOutBack","easeOutBounce","easeInBounce","easeInOutBounce","easeInQuad","easeOutQuad","easeInOutQuad","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","isArrayAnimation","animate","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","AT","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersection","intersectsWithObject","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","allPointsAreOutside","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","noSkew","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","ceil","dimensionsChanged","zoomChanged","shouldRedraw","setTransform","drawingWidth","drawingHeight","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","ImageClass","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","hasStaticDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeObjectWidth","strokePadding","oldWidth","newWidth","changeWidth","renderCircleControl","styleOverride","xSize","sizeX","ySize","sizeY","myLeft","myTop","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","rotationStyleHandler","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","rotationWithSnapping","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","forbidScaling","signX","signY","gestureScale","distance","original","originalDistance","oldScaleX","oldScaleY","scaleObjectFromCorner","scaleObjectX","scaleObjectY","scalingEqually","scalingX","scalingY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewObject","axis","skewingSide","skewKey","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewHandler","originKey","lockSkewingKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingDirection","finalHandler","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","fn","_activeObject","wh","strokeBorders","_drawBorders","drawControlsConnectingLines","_renderControls","styleOptions","shouldDrawBorders","shouldDrawControls","isMoving","drawBorders","forActiveSelection","shouldStroke","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","isTransparent","tolerance","getImageData","alphaChannel","rotatePoint","findIndexRight","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","radiusOnAxisX","radiusOnAxisY","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","cloneStyles","newObj","keyInner","capitalize","string","firstLetterOnly","charAt","escapeXml","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","next","prev","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","doesSomeParentMatch","selectors","parentMatching","parentElement","elementMatchesRule","firstMatching","getGlobalStylesForElement","cssRules","rule","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleObject","parseStyleString","chunk","parseStyleAttribute","colorAttributesMap","setStrokeFillOpacity","attributes","colorAttr","parseAttributes","parentFontSize","ownAttributes","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","rectDefaultValues","rx","ry","RECT_PROPS","Rect","_initRxRy","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","LAYOUT_TYPE_OBJECT_MODIFIED","LAYOUT_TYPE_OBJECT_MODIFYING","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxLeftTop","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","layoutObjects","_context$x","_context$y","layoutObject","_","bubblingContext","NoopLayoutManager","groupDefaultValues","subTargetCheck","interactive","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","groupSVGElements","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","rePathCommand","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","cp1X","cp1Y","cp2X","cp2Y","arcToSegments","large","sweep","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","calcVectorAngle","dtheta","segments","mDelta","th3","ux","uy","vx","vy","ta","tb","CB1","CB2","CB3","CB4","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","tx","ty","segsNorm","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","c3","c4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","totalLength","tempInfo","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","multSignX","multSignY","manyPoints","midPoint","transformPath","pathOffset","pathSegment","newSegment","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","joinPath","pathData","setStyle","elementStyle","setProperty","mergeClipPaths","_b$group","getRandomInt","random","request","xhr","XMLHttpRequest","removeListener","ontimeout","onreadystatechange","readyState","open","send","_assignTransformMatrixProps","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","cropX","cropY","offsetLeft","offsetTop","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","canvasDefaults","centeredKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","_drawSelection","renderTop","setTargetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","_control$getActionHan","getScenePoint","altKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","minX","minY","maxX","maxY","findTarget","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","layoutProps","originalValues","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_fireOverOutEvents","_transformObject","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","klass","newActiveSelection","point1","point2","collectedObjects","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","convertPercentUnitsToValues","valuesToConvert","finalValue","propValue","getValue","parseLinearCoords","parseRadialCoords","parseCoords","Gradient","addColorStop","colorStop","preTransform","sort","needsSwap","minRadius","maxRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","isEmptySVGPath","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","lastPoint","cDistance","adjustedDistance","newPoints","decimate","CIRCLE_PROPS","circleDefaultValues","startAngle","endAngle","Circle","setRadius","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","otherParsedAttributes","CircleBrush","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","getUniqueRects","rects","uniqueRects","uniqueRectsArray","SprayBrush","sprayChunks","sprayChunk","addSprayChunk","renderChunck","chunck","rect","optimizeOverlapping","sprayChunck","density","dotWidthVariance","dotWidth","randomOpacity","PatternBrush","getPatternSrc","dotDistance","patternCanvas","patternCtx","getPattern","pattern","topLeft","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","triangleDefaultValues","Triangle","widthBy2","heightBy2","ellipseDefaultValues","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","stylesCount","letterCount","stylePropertyValue","allStyleObjectPropertiesMatch","graphemeCount","styleObject","stylePropertyHasBeenSet","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","TextSVGExportMixin","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","getHeightOfLine","textBgRects","textSpans","noShadow","textDecoration","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_getLineLeftOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","isJustify","actualStyle","nextStyle","charsToRender","charBox","boxWidth","timeToRender","__charBounds","kernedWidth","leftOffset","heightOfLine","boxStart","currentColor","lastColor","getValueOfPropertyAt","_getSVGLineTopOffset","lineTopOffset","lastHeight","useWhiteSpace","decoration","measuringContext","getMeasuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","_getLeftOffset","_getTopOffset","lineLeftOffset","drawStart","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","shortCut","isLtr","currentDirection","drawingLeft","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","lastDecoration","lastFill","currentDecoration","currentFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","restOfOptions","textContent","textHeightScaleFactor","lineHeightDiff","scaledDiff","textHeight","offX","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","selectionPosition","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","graphemeEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","charDiff","removeFrom","removeTo","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","widthBeforeCursor","bound","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","textAfterCursor","getUpCursorOffset","textBeforeCursor","widthOfCharsOnLine","indexOnLine","charWidth","foundMatch","leftEdge","rightEdge","offsetFromLeftEdge","offsetFromRightEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","protectedDefaultValues","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderCursor","renderSelection","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","textboxDefaultValues","minWidth","dynamicMinWidth","_wordJoiners","splitByGrapheme","Textbox","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","isWrapping","nextLineIndex","nextOffset","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","activeSelectionDefaultValues","multiSelectionStacking","ActiveSelection","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","imageData","originalImageData","pipelineState","originalEl","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","glOptions","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","dWidth","dHeight","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","strict","setFilterBackend","backend","imageDefaultValues","srcFromAttribute","minimumScaleTrigger","imageSmoothing","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","getSvgSrc","origFill","filtered","setSrc","minimumScale","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","goodViewbox","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","hasInvalidAncestor","getMultipleNodes","nodeNames","nodeArray","nodeList","getElementsByTagNameNS","parseUseDirectives","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","cloneNode","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","tagArray","getGradientDefs","elList","gradientDefs","getCSSRules","allRules","styleContents","ruleObj","declaration","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","parseSVGDocument","descendants","localClipPaths","elementParser","loadSVGFromString","parser","DOMParser","parseFromString","loadSVGFromURL","xml","responseXML","parsedDoc","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","newAnchorPointInParentPlane","createPolyActionHandler","createPolyControls","calcPathPointPosition","pathObject","commandIndex","movePathPoint","anchorCommand","pathPositionHandler","pathActionHandler","indexFromPrevCommand","previousCommandType","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","createPathControls","isWebGLPipelineState","isPutImageFaster","sourceCanvas","ArrayBuffer","testContext","testPipelineState","performance","now","drawImageTime","putImageDataTime","highPsourceCode","identityFragmentShader","vertexSource","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","filterOptions","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","blendColorDefaultValues","mode","BlendColor","tg","alpha1","oR","oG","oB","uniform4fv","uColor","mask","blendImageDefaultValues","BlendImage","image","TEXTURE1","calculateMatrix","resources","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","enlivedImage","blurDefaultValues","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","brightnessDefaultValues","brightness","Brightness","uBrightness","colorMatrixDefaultValues","colorsOnly","ColorMatrix","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","contrastDefaultValues","contrast","Contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","convoluteDefaultValues","opaque","Convolute","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","gammaDefaultValues","gamma","Gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","grayscaleDefaultValues","Grayscale","uMode","hueRotationDefaultValues","rotation","HueRotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","invertDefaultValues","invert","Invert","uInvert","uAlpha","noiseDefaultValues","noise","Noise","rand","uNoise","uSeed","pixelateDefaultValues","blocksize","Pixelate","_i","_j","uBlocksize","removeColorDefaultValues","useAlpha","RemoveColor","lowC","highC","uLow","uHigh","resizeDefaultValues","resizeType","lanczosLobes","Resize","uTaps","taps","getFilterWindow","tempScale","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","process","u","weight","fX","fY","ratioX","icenter","ratioY","range2X","cacheLanc","range2Y","lanczos","rcpRatioX","rcpRatioY","srcData","destData","destImg","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","saturationDefaultValues","saturation","Saturation","adjust","uSaturation","vibranceDefaultValues","vibrance","Vibrance","amt","uVibrance"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA,iBAAiB,CAAC;EAAAC,WAAA,GAAA;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbEC,IAAAA,eAAA,oCAc4B,CAAC,CAAA,CAAA;AAE7B;AACF;AACA;AAFEA,IAAAA,eAAA,cAGM,EAAE,CAAA,CAAA;AAER;AACF;AACA;AACA;IAHEA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAKE,OA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ACA;AACA;AACA;AACA;AAPEpC,IAAAA,eAAA,kBAQU,IAAI,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVEA,IAAAA,eAAA,qBAWa+H,KAAK,CAAA,CAAA;AAElB;AACF;AACA;AACA;AACA;AACA;AACA;AANE/H,IAAAA,eAAA,gBAOQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXEA,IAAAA,eAAA,kBAYU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,kBAMU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,sBAMc,WAAW,CAAA,CAAA;AAEzB;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,yBAMiB,KAAK,CAAA,CAAA;AAGpBS,IAAAA,MAAM,CAACC,MAAM,CAAC,IAAI,EAAE0B,OAAO,CAAC,CAAA;AAC9B,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;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AAK;AACrBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,mBAAmB,EAAE,KAAK;AAE1B3B,EAAAA,cAAc,EAAE,kBAAkB;AAElC5N,EAAAA,sBAAsB,EAAE,KAAA;AAC1B,CAAC;;ACnPD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMwP,gBAAgB,SACnBn6C,YAAY,CAEtB;EAAAjvB,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAAO,SAAA,CAAA,CAAA;AAGE;AAQA;AAUA;AASA;AAKA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAKE;AAKA;AACF;AACA;AACA;AAHEN,IAAAA,eAAA,kBAI0B,EAAE,CAAA,CAAA;AAS5B;AACF;AACA;AACA;AACA;AAJEA,IAAAA,eAAA,0BAKkC,EAAE,CAAA,CAAA;AAEpC;AACF;AACA;AACA;AACA;IAJEA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAOA;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMsC,IAAI,CAAA,CAAA;AAE1C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,yBAaW,IAAI,CAAA,CAAA;AAEf;AACF;AACA;AACA;AACA;AACA;AALEA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,GAAG,GAAG,CAAC,CAAA;AAChD,KAAA;AACF,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACEzP,EAAAA,eAAeA,CACbr6G,EAAyB,EACzBm4G,gBAA0C,EAC1C;IACAn4G,EAAE,CAACo6G,SAAS,CAACjC,gBAAgB,CAAC4R,SAAS,EAAE,CAAC,IAAI,CAACH,QAAQ,CAAC,CAAA;AAC1D,GAAA;AAEAnd,EAAAA,cAAcA,GAAG;AACf,IAAA,OAAO,IAAI,CAACmd,QAAQ,KAAK,CAAC,CAAA;AAC5B,GAAA;AACF,CAAA;AAzDE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEvsH,eAAA,CADWwsH,QAAQ,EAAA,MAAA,EAWL,UAAU,CAAA,CAAA;AAAAxsH,eAAA,CAXbwsH,QAAQ,EAAA,UAAA,EAaDF,qBAAqB,CAAA,CAAA;AAAAtsH,eAAA,CAb5BwsH,QAAQ,EAeO,kBAAA,EAAA,CAAC,WAAW,CAAC,CAAA,CAAA;AA6CzCljH,aAAa,CAACP,QAAQ,CAACyjH,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/index.node.mjs b/dist/index.node.mjs index 7c4801b5236..cb243bd1c0a 100644 --- a/dist/index.node.mjs +++ b/dist/index.node.mjs @@ -461,7 +461,7 @@ class Cache { } const cache = new Cache(); -var version = "6.5.1"; +var version = "6.5.2"; // use this syntax so babel plugin see this import here const VERSION = version; @@ -2431,6 +2431,7 @@ class Color { * @returns {TRGBAColorSource} */ _tryParsingColor(color) { + color = color.toLowerCase(); if (color in ColorNameMap) { color = ColorNameMap[color]; } @@ -6900,8 +6901,8 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry { // for sure this ALIASING_LIMIT is slightly creating problem // in situation in which the cache canvas gets an upper limit // also objectScale contains already scaleX and scaleY - width: neededX + ALIASING_LIMIT, - height: neededY + ALIASING_LIMIT, + width: Math.ceil(neededX + ALIASING_LIMIT), + height: Math.ceil(neededY + ALIASING_LIMIT), zoomX: objectScale.x, zoomY: objectScale.y, x: neededX, @@ -6918,51 +6919,30 @@ let FabricObject$1 = class FabricObject extends ObjectGeometry { _updateCacheCanvas() { const canvas = this._cacheCanvas, context = this._cacheContext, - dims = this._limitCacheSize(this._getCacheCanvasDimensions()), - minCacheSize = config.minCacheSideLimit, - width = dims.width, - height = dims.height, - zoomX = dims.zoomX, - zoomY = dims.zoomY, + { + width, + height, + zoomX, + zoomY, + x, + y + } = this._limitCacheSize(this._getCacheCanvasDimensions()), dimensionsChanged = width !== canvas.width || height !== canvas.height, zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY; if (!canvas || !context) { return false; } - let drawingWidth, - drawingHeight, - shouldRedraw = dimensionsChanged || zoomChanged, - additionalWidth = 0, - additionalHeight = 0, - shouldResizeCanvas = false; - if (dimensionsChanged) { - const canvasWidth = this._cacheCanvas.width, - canvasHeight = this._cacheCanvas.height, - sizeGrowing = width > canvasWidth || height > canvasHeight, - sizeShrinking = (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) && canvasWidth > minCacheSize && canvasHeight > minCacheSize; - shouldResizeCanvas = sizeGrowing || sizeShrinking; - if (sizeGrowing && !dims.capped && (width > minCacheSize || height > minCacheSize)) { - additionalWidth = width * 0.1; - additionalHeight = height * 0.1; - } - } - if (isTextObject(this) && this.path) { - shouldRedraw = true; - shouldResizeCanvas = true; - // IMHO in those lines we are using zoomX and zoomY not the this version. - additionalWidth += this.getHeightOfLine(0) * this.zoomX; - additionalHeight += this.getHeightOfLine(0) * this.zoomY; - } + const shouldRedraw = dimensionsChanged || zoomChanged; if (shouldRedraw) { - if (shouldResizeCanvas) { - canvas.width = Math.ceil(width + additionalWidth); - canvas.height = Math.ceil(height + additionalHeight); + if (width !== canvas.width || height !== canvas.height) { + canvas.width = width; + canvas.height = height; } else { context.setTransform(1, 0, 0, 1, 0, 0); context.clearRect(0, 0, canvas.width, canvas.height); } - drawingWidth = dims.x / 2; - drawingHeight = dims.y / 2; + const drawingWidth = x / 2; + const drawingHeight = y / 2; this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth; this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight; context.translate(this.cacheTranslationX, this.cacheTranslationY); @@ -15320,9 +15300,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas { * @private */ _resetTransformEventData() { - this._target = undefined; - this._pointer = undefined; - this._absolutePointer = undefined; + this._target = this._pointer = this._absolutePointer = undefined; } /** @@ -18526,8 +18504,6 @@ class StyledText extends FabricObject { * has no other properties, then it is also deleted. Finally, * if the line containing that character has no other characters * then it also is deleted. - * - * @param {string} property The property to compare between characters and text. */ cleanStyle(property) { if (!this.styles) { @@ -18573,7 +18549,6 @@ class StyledText extends FabricObject { graphemeCount += this._textLines[i].length; } if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) { - // @ts-expect-error conspiracy theory of TS this[property] = stylePropertyValue; this.removeStyle(property); } @@ -21566,10 +21541,8 @@ class ITextKeyBehavior extends ITextBehavior { } const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap; if (e.keyCode in keyMap) { - // @ts-expect-error legacy method calling pattern this[keyMap[e.keyCode]](e); } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) { - // @ts-expect-error legacy method calling pattern this[this.ctrlKeysMapDown[e.keyCode]](e); } else { return; @@ -21598,7 +21571,6 @@ class ITextKeyBehavior extends ITextBehavior { return; } if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) { - // @ts-expect-error legacy method calling pattern this[this.ctrlKeysMapUp[e.keyCode]](e); } else { return; @@ -22089,8 +22061,6 @@ class ITextClickBehavior extends ITextKeyBehavior { this.__lastLastClickTime = +new Date(); this.__lastPointer = {}; this.on('mousedown', this.onMouseDown); - - // @ts-expect-error in reality it is an IText instance this.draggableTextDelegate = new DraggableTextDelegate(this); super.initBehavior(); } @@ -23930,12 +23900,8 @@ class WebGLFilterBackend { cachedTexture = this.getCachedTexture(cacheKey, source); } const pipelineState = { - originalWidth: source.width || - // @ts-expect-error is this a bug? should this be naturalWidth? or is this the pipeline state? - source.originalWidth || 0, - originalHeight: source.height || - // @ts-expect-error is this a bug? should this be naturalHeight? or is this the pipeline state? - source.originalHeight || 0, + originalWidth: source.width || source.naturalWidth || 0, + originalHeight: source.height || source.naturalHeight || 0, sourceWidth: width, sourceHeight: height, destinationWidth: width, @@ -26093,65 +26059,70 @@ class BlendColor extends BaseFilter { } } = _ref; const source = new Color(this.color).getSource(); - const tr = source[0] * this.alpha; - const tg = source[1] * this.alpha; - const tb = source[2] * this.alpha; - const alpha1 = 1 - this.alpha; + const alpha = this.alpha; + const tr = source[0] * alpha; + const tg = source[1] * alpha; + const tb = source[2] * alpha; + const alpha1 = 1 - alpha; for (let i = 0; i < data.length; i += 4) { const r = data[i]; const g = data[i + 1]; const b = data[i + 2]; + let oR, oG, oB; switch (this.mode) { case 'multiply': - data[i] = r * tr / 255; - data[i + 1] = g * tg / 255; - data[i + 2] = b * tb / 255; + oR = r * tr / 255; + oG = g * tg / 255; + oB = b * tb / 255; break; case 'screen': - data[i] = 255 - (255 - r) * (255 - tr) / 255; - data[i + 1] = 255 - (255 - g) * (255 - tg) / 255; - data[i + 2] = 255 - (255 - b) * (255 - tb) / 255; + oR = 255 - (255 - r) * (255 - tr) / 255; + oG = 255 - (255 - g) * (255 - tg) / 255; + oB = 255 - (255 - b) * (255 - tb) / 255; break; case 'add': - data[i] = r + tr; - data[i + 1] = g + tg; - data[i + 2] = b + tb; + oR = r + tr; + oG = g + tg; + oB = b + tb; break; case 'difference': - data[i] = Math.abs(r - tr); - data[i + 1] = Math.abs(g - tg); - data[i + 2] = Math.abs(b - tb); + oR = Math.abs(r - tr); + oG = Math.abs(g - tg); + oB = Math.abs(b - tb); break; case 'subtract': - data[i] = r - tr; - data[i + 1] = g - tg; - data[i + 2] = b - tb; + oR = r - tr; + oG = g - tg; + oB = b - tb; break; case 'darken': - data[i] = Math.min(r, tr); - data[i + 1] = Math.min(g, tg); - data[i + 2] = Math.min(b, tb); + oR = Math.min(r, tr); + oG = Math.min(g, tg); + oB = Math.min(b, tb); break; case 'lighten': - data[i] = Math.max(r, tr); - data[i + 1] = Math.max(g, tg); - data[i + 2] = Math.max(b, tb); + oR = Math.max(r, tr); + oG = Math.max(g, tg); + oB = Math.max(b, tb); break; case 'overlay': - data[i] = tr < 128 ? 2 * r * tr / 255 : 255 - 2 * (255 - r) * (255 - tr) / 255; - data[i + 1] = tg < 128 ? 2 * g * tg / 255 : 255 - 2 * (255 - g) * (255 - tg) / 255; - data[i + 2] = tb < 128 ? 2 * b * tb / 255 : 255 - 2 * (255 - b) * (255 - tb) / 255; + oR = tr < 128 ? 2 * r * tr / 255 : 255 - 2 * (255 - r) * (255 - tr) / 255; + oG = tg < 128 ? 2 * g * tg / 255 : 255 - 2 * (255 - g) * (255 - tg) / 255; + oB = tb < 128 ? 2 * b * tb / 255 : 255 - 2 * (255 - b) * (255 - tb) / 255; break; case 'exclusion': - data[i] = tr + r - 2 * tr * r / 255; - data[i + 1] = tg + g - 2 * tg * g / 255; - data[i + 2] = tb + b - 2 * tb * b / 255; + oR = tr + r - 2 * tr * r / 255; + oG = tg + g - 2 * tg * g / 255; + oB = tb + b - 2 * tb * b / 255; break; case 'tint': - data[i] = tr + r * alpha1; - data[i + 1] = tg + g * alpha1; - data[i + 2] = tb + b * alpha1; + oR = tr + r * alpha1; + oG = tg + g * alpha1; + oB = tb + b * alpha1; } + data[i] = oR; + data[i + 1] = oG; + data[i + 2] = oB; } } @@ -26560,9 +26531,9 @@ class Brightness extends BaseFilter { } = _ref; const brightness = Math.round(this.brightness * 255); for (let i = 0; i < data.length; i += 4) { - data[i] = data[i] + brightness; - data[i + 1] = data[i + 1] + brightness; - data[i + 2] = data[i + 2] + brightness; + data[i] += brightness; + data[i + 1] += brightness; + data[i + 2] += brightness; } } isNeutralState() { @@ -26634,16 +26605,15 @@ class ColorMatrix extends BaseFilter { const r = data[i]; const g = data[i + 1]; const b = data[i + 2]; - if (colorsOnly) { - data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255; - data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255; - data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255; - } else { + data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255; + data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255; + data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255; + if (!colorsOnly) { const a = data[i + 3]; - data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255; - data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255; - data[i + 2] = r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255; - data[i + 3] = r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255; + data[i] += a * m[3]; + data[i + 1] += a * m[8]; + data[i + 2] += a * m[13]; + data[i + 3] += a * m[18]; } } } @@ -26689,7 +26659,6 @@ classRegistry.setClass(ColorMatrix); function createColorMatrixFilter(key, matrix) { var _Class; const newClass = (_Class = class newClass extends ColorMatrix { - //@ts-expect-error TS wants matrix to be exported. toObject() { return { type: this.type, @@ -26740,7 +26709,6 @@ class Composed extends BaseFilter { * Serialize this filter into JSON. * @returns {Object} A JSON representation of this filter. */ - //@ts-expect-error TS doesn't like this toObject toObject() { return { type: this.type, @@ -27120,20 +27088,21 @@ class Grayscale extends BaseFilter { } } = _ref; for (let i = 0, value; i < data.length; i += 4) { + const r = data[i]; + const g = data[i + 1]; + const b = data[i + 2]; switch (this.mode) { case 'average': - value = (data[i] + data[i + 1] + data[i + 2]) / 3; + value = (r + g + b) / 3; break; case 'lightness': - value = (Math.min(data[i], data[i + 1], data[i + 2]) + Math.max(data[i], data[i + 1], data[i + 2])) / 2; + value = (Math.min(r, g, b) + Math.max(r, g, b)) / 2; break; case 'luminosity': - value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2]; + value = 0.21 * r + 0.72 * g + 0.07 * b; break; } - data[i] = value; - data[i + 1] = value; - data[i + 2] = value; + data[i + 2] = data[i + 1] = data[i] = value; } } getCacheKey() { @@ -27168,9 +27137,9 @@ _defineProperty(Grayscale, "defaults", grayscaleDefaultValues); _defineProperty(Grayscale, "uniformLocations", ['uMode']); classRegistry.setClass(Grayscale); -const hueRotationDefaultValues = { +const hueRotationDefaultValues = _objectSpread2(_objectSpread2({}, colorMatrixDefaultValues), {}, { rotation: 0 -}; +}); /** * HueRotation filter class @@ -27189,16 +27158,7 @@ class HueRotation extends ColorMatrix { aThird = 1 / 3, aThirdSqtSin = Math.sqrt(aThird) * sine, OneMinusCos = 1 - cosine; - this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0]; - this.matrix[0] = cosine + OneMinusCos / 3; - this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin; - this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin; - this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin; - this.matrix[6] = cosine + aThird * OneMinusCos; - this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin; - this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin; - this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin; - this.matrix[12] = cosine + aThird * OneMinusCos; + this.matrix = [cosine + OneMinusCos / 3, aThird * OneMinusCos - aThirdSqtSin, aThird * OneMinusCos + aThirdSqtSin, 0, 0, aThird * OneMinusCos + aThirdSqtSin, cosine + aThird * OneMinusCos, aThird * OneMinusCos - aThirdSqtSin, 0, 0, aThird * OneMinusCos - aThirdSqtSin, aThird * OneMinusCos + aThirdSqtSin, cosine + aThird * OneMinusCos, 0, 0, 0, 0, 0, 1, 0]; } isNeutralState() { return this.rotation === 0; @@ -27207,8 +27167,6 @@ class HueRotation extends ColorMatrix { this.calculateMatrix(); super.applyTo(options); } - - //@ts-expect-error TS and classes with different methods toObject() { return { type: this.type, @@ -27978,10 +27936,13 @@ class Saturation extends BaseFilter { } = _ref; const adjust = -this.saturation; for (let i = 0; i < data.length; i += 4) { - const max = Math.max(data[i], data[i + 1], data[i + 2]); - data[i] += max !== data[i] ? (max - data[i]) * adjust : 0; - data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0; - data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0; + const r = data[i]; + const g = data[i + 1]; + const b = data[i + 2]; + const max = Math.max(r, g, b); + data[i] += max !== r ? (max - r) * adjust : 0; + data[i + 1] += max !== g ? (max - g) * adjust : 0; + data[i + 2] += max !== b ? (max - b) * adjust : 0; } } @@ -28045,12 +28006,15 @@ class Vibrance extends BaseFilter { } = _ref; const adjust = -this.vibrance; for (let i = 0; i < data.length; i += 4) { - const max = Math.max(data[i], data[i + 1], data[i + 2]); - const avg = (data[i] + data[i + 1] + data[i + 2]) / 3; + const r = data[i]; + const g = data[i + 1]; + const b = data[i + 2]; + const max = Math.max(r, g, b); + const avg = (r + g + b) / 3; const amt = Math.abs(max - avg) * 2 / 255 * adjust; - data[i] += max !== data[i] ? (max - data[i]) * amt : 0; - data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0; - data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0; + data[i] += max !== r ? (max - r) * amt : 0; + data[i + 1] += max !== g ? (max - g) * amt : 0; + data[i + 2] += max !== b ? (max - b) * amt : 0; } } diff --git a/dist/index.node.mjs.map b/dist/index.node.mjs.map index cb1ec7afbf8..6aea6c69ac6 100644 --- a/dist/index.node.mjs.map +++ b/dist/index.node.mjs.map @@ -1 +1 @@ -{"version":3,"file":"index.node.mjs","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/filters/GLProbes/NodeGLProbe.ts","../src/env/node.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/constants.ts","../src/color/util.ts","../src/color/Color.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/rotatePoint.ts","../src/util/internals/findRight.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/elementMatchesRule.ts","../src/parser/getGlobalStylesForElement.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleObject.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/CanvasOptions.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/brushes/CircleBrush.ts","../src/brushes/SprayBrush.ts","../src/brushes/PatternBrush.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/parseUseDirectives.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/shaders/blur.ts","../src/filters/Blur.ts","../src/filters/shaders/brightness.ts","../src/filters/Brightness.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/shaders/constrast.ts","../src/filters/Contrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/shaders/invert.ts","../src/filters/Invert.ts","../src/filters/shaders/noise.ts","../src/filters/Noise.ts","../src/filters/shaders/pixelate.ts","../src/filters/Pixelate.ts","../src/filters/shaders/removeColor.ts","../src/filters/RemoveColor.ts","../src/filters/Resize.ts","../src/filters/shaders/saturation.ts","../src/filters/Saturation.ts","../src/filters/shaders/vibrance.ts","../src/filters/Vibrance.ts","../index.node.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { GLProbe } from './GLProbe';\n\n/**\n * @todo GL rendering in node is possible:\n * - https://github.com/stackgl/headless-gl\n * - https://github.com/akira-cn/node-canvas-webgl\n */\nexport class NodeGLProbe extends GLProbe {\n queryWebGL() {\n // noop\n }\n isSupported() {\n return false;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport type { Canvas as NodeCanvas } from 'canvas';\nimport { JSDOM } from 'jsdom';\n// @ts-expect-error internal import\nimport utils from 'jsdom/lib/jsdom/living/generated/utils.js';\nimport { NodeGLProbe } from '../filters/GLProbes/NodeGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst { implForWrapper: jsdomImplForWrapper } = utils;\n\nconst copyPasteData: TCopyPasteData = {};\n\nconst { window: JSDOMWindow } = new JSDOM(\n decodeURIComponent(\n '%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E',\n ),\n {\n resources: 'usable',\n // needed for `requestAnimationFrame`\n pretendToBeVisual: true,\n },\n);\n\nexport const getNodeCanvas = (canvasEl: HTMLCanvasElement) => {\n const impl = jsdomImplForWrapper(canvasEl);\n return (impl._canvas || impl._image) as NodeCanvas;\n};\n\nexport const dispose = (element: Element) => {\n const impl = jsdomImplForWrapper(element);\n if (impl) {\n impl._image = null;\n impl._canvas = null;\n // unsure if necessary\n impl._currentSrc = null;\n impl._attributes = null;\n impl._classList = null;\n }\n};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document: JSDOMWindow.document,\n window: JSDOMWindow,\n isTouchSupported: false,\n WebGLProbe: new NodeGLProbe(),\n dispose,\n copyPasteData,\n };\n};\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport {\n isFiller,\n isSerializableFiller,\n isTextObject,\n} from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: neededX + ALIASING_LIMIT,\n height: neededY + ALIASING_LIMIT,\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n minCacheSize = config.minCacheSideLimit,\n width = dims.width,\n height = dims.height,\n zoomX = dims.zoomX,\n zoomY = dims.zoomY,\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n let drawingWidth,\n drawingHeight,\n shouldRedraw = dimensionsChanged || zoomChanged,\n additionalWidth = 0,\n additionalHeight = 0,\n shouldResizeCanvas = false;\n\n if (dimensionsChanged) {\n const canvasWidth = (this._cacheCanvas as HTMLCanvasElement).width,\n canvasHeight = (this._cacheCanvas as HTMLCanvasElement).height,\n sizeGrowing = width > canvasWidth || height > canvasHeight,\n sizeShrinking =\n (width < canvasWidth * 0.9 || height < canvasHeight * 0.9) &&\n canvasWidth > minCacheSize &&\n canvasHeight > minCacheSize;\n shouldResizeCanvas = sizeGrowing || sizeShrinking;\n if (\n sizeGrowing &&\n !dims.capped &&\n (width > minCacheSize || height > minCacheSize)\n ) {\n additionalWidth = width * 0.1;\n additionalHeight = height * 0.1;\n }\n }\n if (isTextObject(this) && this.path) {\n shouldRedraw = true;\n shouldResizeCanvas = true;\n // IMHO in those lines we are using zoomX and zoomY not the this version.\n additionalWidth += this.getHeightOfLine(0) * this.zoomX!;\n additionalHeight += this.getHeightOfLine(0) * this.zoomY!;\n }\n if (shouldRedraw) {\n if (shouldResizeCanvas) {\n canvas.width = Math.ceil(width + additionalWidth);\n canvas.height = Math.ceil(height + additionalHeight);\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n drawingWidth = dims.x / 2;\n drawingHeight = dims.y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = undefined;\n this._pointer = undefined;\n this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n *\n * @param {string} property The property to compare between characters and text.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n // @ts-expect-error conspiracy theory of TS\n this[property as keyof this] = stylePropertyValue;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n // @ts-expect-error readonly\n ...pick(this, (this.constructor as typeof StyledText)._styleProperties),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n // @ts-expect-error legacy method calling pattern\n this[keyMap[e.keyCode]](e);\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapDown[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n // @ts-expect-error legacy method calling pattern\n this[this.ctrlKeysMapUp[e.keyCode]](e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\n\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n // @ts-expect-error in reality it is an IText instance\n this.draggableTextDelegate = new DraggableTextDelegate(this);\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n // @ts-expect-error is this a bug? should this be naturalWidth? or is this the pipeline state?\n (source as HTMLImageElement).originalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n // @ts-expect-error is this a bug? should this be naturalHeight? or is this the pipeline state?\n (source as HTMLImageElement).originalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & OwnProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof OwnProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as OwnProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const tr = source[0] * this.alpha;\n const tg = source[1] * this.alpha;\n const tb = source[2] * this.alpha;\n const alpha1 = 1 - this.alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n break;\n case 'screen':\n data[i] = 255 - ((255 - r) * (255 - tr)) / 255;\n data[i + 1] = 255 - ((255 - g) * (255 - tg)) / 255;\n data[i + 2] = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n data[i] = r + tr;\n data[i + 1] = g + tg;\n data[i + 2] = b + tb;\n break;\n case 'difference':\n data[i] = Math.abs(r - tr);\n data[i + 1] = Math.abs(g - tg);\n data[i + 2] = Math.abs(b - tb);\n break;\n case 'subtract':\n data[i] = r - tr;\n data[i + 1] = g - tg;\n data[i + 2] = b - tb;\n break;\n case 'darken':\n data[i] = Math.min(r, tr);\n data[i + 1] = Math.min(g, tg);\n data[i + 2] = Math.min(b, tb);\n break;\n case 'lighten':\n data[i] = Math.max(r, tr);\n data[i + 1] = Math.max(g, tg);\n data[i + 2] = Math.max(b, tb);\n break;\n case 'overlay':\n data[i] =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n data[i + 1] =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n data[i + 2] =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n data[i] = tr + r - (2 * tr * r) / 255;\n data[i + 1] = tg + g - (2 * tg * g) / 255;\n data[i + 2] = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n data[i] = tr + r * alpha1;\n data[i + 1] = tg + g * alpha1;\n data[i + 2] = tb + b * alpha1;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] = data[i] + brightness;\n data[i + 1] = data[i + 1] + brightness;\n data[i + 2] = data[i + 2] + brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\ntype ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n if (colorsOnly) {\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n } else {\n const a = data[i + 3];\n data[i] = r * m[0] + g * m[1] + b * m[2] + a * m[3] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + a * m[8] + m[9] * 255;\n data[i + 2] =\n r * m[10] + g * m[11] + b * m[12] + a * m[13] + m[14] * 255;\n data[i + 3] =\n r * m[15] + g * m[16] + b * m[17] + a * m[18] + m[19] * 255;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject() {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n //@ts-expect-error TS wants matrix to be exported.\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<'Composed', ComposedOwnProps> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n //@ts-expect-error TS doesn't like this toObject\n toObject(): {\n type: 'Composed';\n subFilters: ReturnType['toObject']>[];\n } {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n switch (this.mode) {\n case 'average':\n value = (data[i] + data[i + 1] + data[i + 2]) / 3;\n break;\n case 'lightness':\n value =\n (Math.min(data[i], data[i + 1], data[i + 2]) +\n Math.max(data[i], data[i + 1], data[i + 2])) /\n 2;\n break;\n case 'luminosity':\n value = 0.21 * data[i] + 0.72 * data[i + 1] + 0.07 * data[i + 2];\n break;\n }\n\n data[i] = value;\n data[i + 1] = value;\n data[i + 2] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport { ColorMatrix } from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0];\n this.matrix[0] = cosine + OneMinusCos / 3;\n this.matrix[1] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[2] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[5] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[6] = cosine + aThird * OneMinusCos;\n this.matrix[7] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[10] = aThird * OneMinusCos - aThirdSqtSin;\n this.matrix[11] = aThird * OneMinusCos + aThirdSqtSin;\n this.matrix[12] = cosine + aThird * OneMinusCos;\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n //@ts-expect-error TS and classes with different methods\n toObject(): { type: 'HueRotation'; rotation: number } {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentShader = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n data[i] += max !== data[i] ? (max - data[i]) * adjust : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * adjust : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const max = Math.max(data[i], data[i + 1], data[i + 2]);\n const avg = (data[i] + data[i + 1] + data[i + 2]) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== data[i] ? (max - data[i]) * amt : 0;\n data[i + 1] += max !== data[i + 1] ? (max - data[i + 1]) * amt : 0;\n data[i + 2] += max !== data[i + 2] ? (max - data[i + 2]) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n","// First we set the env variable\n\nimport { setEnv } from './src/env';\nimport { getEnv, getNodeCanvas } from './src/env/node';\n\nsetEnv(getEnv());\n\n// After the env is set we can export everything and expose specific node functionality\n\nimport type { JpegConfig, PngConfig } from 'canvas';\nimport {\n Canvas as CanvasBase,\n StaticCanvas as StaticCanvasBase,\n} from './fabric';\nimport { FabricObject } from './src/shapes/Object/Object';\n\nFabricObject.ownDefaults.objectCaching = false;\n\nexport * from './fabric';\n\nexport class StaticCanvas extends StaticCanvasBase {\n getNodeCanvas() {\n return getNodeCanvas(this.getElement());\n }\n createPNGStream(opts?: PngConfig) {\n return this.getNodeCanvas().createPNGStream(opts);\n }\n createJPEGStream(opts?: JpegConfig) {\n return this.getNodeCanvas().createJPEGStream(opts);\n }\n}\n\n/**\n * **NOTICE**:\n * {@link Canvas} is designed for interactivity.\n * Therefore, using it in node has no benefit.\n * Use {@link StaticCanvas} instead.\n */\nexport class Canvas extends CanvasBase {\n getNodeCanvas() {\n return getNodeCanvas(this.getElement());\n }\n createPNGStream(opts?: PngConfig) {\n return this.getNodeCanvas().createPNGStream(opts);\n }\n createJPEGStream(opts?: JpegConfig) {\n return this.getNodeCanvas().createJPEGStream(opts);\n }\n}\n"],"names":["BaseConfiguration","constructor","_defineProperty","window","devicePixelRatio","Configuration","config","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","fontFamilys","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","env","setEnv","value","getBrowserEnv","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","NodeGLProbe","implForWrapper","jsdomImplForWrapper","utils","JSDOMWindow","JSDOM","decodeURIComponent","resources","pretendToBeVisual","getNodeCanvas","canvasEl","impl","_canvas","_image","element","_currentSrc","_attributes","_classList","Cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","cache","VERSION","version","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","ALIASING_LIMIT","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","ClassRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","classRegistry","AnimationRegistry","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","runningAnimations","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","onceHandler","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","idx","cos","angle","angleSlice","abs","sin","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","rotated","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","createElement","createImage","copyCanvasElement","_newCanvas$getContext","newCanvas","createCanvasElementFor","drawImage","toDataURL","format","quality","isHTMLCanvas","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","reRGBa","reHSLa","reHex","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","fullHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherAlpha","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","match1degrees","parseAngletoDegrees","fromHex","isShortNotation","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","getSvgAttributes","commonAttributes","parseUnit","fontSize","unit","exec","dpi","DPI","parseAlign","align","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","inlineStyle","colorValue","opacityValue","toLive","opacity","createSVGRect","svgColor","w","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","_renderText","isPath","_renderPathCommands","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","getElementOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","shouldInvert","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getTouchInfo","event","touchProp","changedTouches","getPointer","scroll","_evt","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","removeTransformFromObject","inverted","finalTransform","calcOwnMatrix","applyTransformToObject","addTransformToObject","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","to","sendPointToPlane","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","getActionFromCorner","alreadySelected","corner","control","controls","getActionName","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","getTotalAngle","cornerAngle","normalizePoint","getRelativeCenterPoint","translateToGivenOrigin","p2","getLocalPoint","padding","localPoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","svgValidTagNames","svgViewBoxElements","svgInvalidAncestors","svgValidParents","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","shadowDefaultValues","blur","affectStroke","nonScaling","Shadow","parseShadow","shadowStr","replace","BLUR_BOX","fBoxX","fBoxY","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","centeredRotation","centeredScaling","dirty","interactiveObjectDefaultValues","noScaleCache","lockMovementX","lockMovementY","lockRotation","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","cornerSize","touchCornerSize","transparentCorners","cornerColor","cornerStrokeColor","cornerStyle","cornerDashArray","hasControls","borderColor","borderDashArray","borderOpacityWhenMoving","borderScaleFactor","hasBorders","selectionBackgroundColor","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","normalize","c","asin","elastic","defaultEasing","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInElastic","normA","normS","normP","easeOutElastic","normC","easeInOutElastic","easeInBack","easeOutBack","easeInOutBack","easeOutBounce","easeInBounce","easeInOutBounce","easeInQuad","easeOutQuad","easeInOutQuad","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","isArrayAnimation","animate","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","AT","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersection","intersectsWithObject","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","allPointsAreOutside","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","noSkew","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","minCacheSize","dimensionsChanged","zoomChanged","drawingWidth","drawingHeight","shouldRedraw","additionalWidth","additionalHeight","shouldResizeCanvas","canvasWidth","canvasHeight","sizeGrowing","sizeShrinking","getHeightOfLine","ceil","setTransform","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","ImageClass","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","hasStaticDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeObjectWidth","strokePadding","oldWidth","newWidth","changeWidth","renderCircleControl","styleOverride","xSize","sizeX","ySize","sizeY","myLeft","myTop","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","rotationStyleHandler","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","rotationWithSnapping","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","forbidScaling","signX","signY","gestureScale","distance","original","originalDistance","oldScaleX","oldScaleY","scaleObjectFromCorner","scaleObjectX","scaleObjectY","scalingEqually","scalingX","scalingY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewObject","axis","skewingSide","skewKey","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewHandler","originKey","lockSkewingKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingDirection","finalHandler","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","fn","_activeObject","wh","strokeBorders","_drawBorders","drawControlsConnectingLines","_renderControls","styleOptions","shouldDrawBorders","shouldDrawControls","isMoving","drawBorders","forActiveSelection","shouldStroke","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","isTransparent","tolerance","getImageData","alphaChannel","rotatePoint","findIndexRight","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","radiusOnAxisX","radiusOnAxisY","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","cloneStyles","newObj","keyInner","capitalize","string","firstLetterOnly","charAt","escapeXml","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","next","prev","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","doesSomeParentMatch","selectors","parentMatching","parentElement","elementMatchesRule","firstMatching","getGlobalStylesForElement","cssRules","rule","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleObject","parseStyleString","chunk","parseStyleAttribute","colorAttributesMap","setStrokeFillOpacity","attributes","colorAttr","parseAttributes","parentFontSize","ownAttributes","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","rectDefaultValues","rx","ry","RECT_PROPS","Rect","_initRxRy","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","LAYOUT_TYPE_OBJECT_MODIFIED","LAYOUT_TYPE_OBJECT_MODIFYING","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxLeftTop","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","layoutObjects","_context$x","_context$y","layoutObject","_","bubblingContext","NoopLayoutManager","groupDefaultValues","subTargetCheck","interactive","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","groupSVGElements","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","rePathCommand","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","cp1X","cp1Y","cp2X","cp2Y","arcToSegments","large","sweep","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","calcVectorAngle","dtheta","segments","mDelta","th3","ux","uy","vx","vy","ta","tb","CB1","CB2","CB3","CB4","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","tx","ty","segsNorm","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","c3","c4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","totalLength","tempInfo","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","multSignX","multSignY","manyPoints","midPoint","transformPath","pathOffset","pathSegment","newSegment","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","joinPath","pathData","setStyle","elementStyle","setProperty","mergeClipPaths","_b$group","getRandomInt","random","request","xhr","XMLHttpRequest","removeListener","ontimeout","onreadystatechange","readyState","open","send","_assignTransformMatrixProps","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","cropX","cropY","offsetLeft","offsetTop","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","canvasDefaults","centeredKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","_drawSelection","renderTop","setTargetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","_control$getActionHan","getScenePoint","altKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","minX","minY","maxX","maxY","findTarget","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","layoutProps","originalValues","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_fireOverOutEvents","_transformObject","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","klass","newActiveSelection","point1","point2","collectedObjects","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","convertPercentUnitsToValues","valuesToConvert","finalValue","propValue","getValue","parseLinearCoords","parseRadialCoords","parseCoords","Gradient","addColorStop","colorStop","preTransform","sort","needsSwap","minRadius","maxRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","isEmptySVGPath","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","lastPoint","cDistance","adjustedDistance","newPoints","decimate","CIRCLE_PROPS","circleDefaultValues","startAngle","endAngle","Circle","setRadius","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","otherParsedAttributes","CircleBrush","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","getUniqueRects","rects","uniqueRects","uniqueRectsArray","SprayBrush","sprayChunks","sprayChunk","addSprayChunk","renderChunck","chunck","rect","optimizeOverlapping","sprayChunck","density","dotWidthVariance","dotWidth","randomOpacity","PatternBrush","getPatternSrc","dotDistance","patternCanvas","patternCtx","getPattern","pattern","topLeft","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","triangleDefaultValues","Triangle","widthBy2","heightBy2","ellipseDefaultValues","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","stylesCount","letterCount","stylePropertyValue","allStyleObjectPropertiesMatch","graphemeCount","styleObject","stylePropertyHasBeenSet","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","TextSVGExportMixin","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","textBgRects","textSpans","noShadow","textDecoration","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_getLineLeftOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","isJustify","actualStyle","nextStyle","charsToRender","charBox","boxWidth","timeToRender","__charBounds","kernedWidth","leftOffset","heightOfLine","boxStart","currentColor","lastColor","getValueOfPropertyAt","_getSVGLineTopOffset","lineTopOffset","lastHeight","useWhiteSpace","decoration","measuringContext","getMeasuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","_getLeftOffset","_getTopOffset","lineLeftOffset","drawStart","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","shortCut","isLtr","currentDirection","drawingLeft","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","lastDecoration","lastFill","currentDecoration","currentFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","restOfOptions","textContent","textHeightScaleFactor","lineHeightDiff","scaledDiff","textHeight","offX","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","selectionPosition","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","graphemeEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","charDiff","removeFrom","removeTo","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","widthBeforeCursor","bound","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","textAfterCursor","getUpCursorOffset","textBeforeCursor","widthOfCharsOnLine","indexOnLine","charWidth","foundMatch","leftEdge","rightEdge","offsetFromLeftEdge","offsetFromRightEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","protectedDefaultValues","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderCursor","renderSelection","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","textboxDefaultValues","minWidth","dynamicMinWidth","_wordJoiners","splitByGrapheme","Textbox","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","isWrapping","nextLineIndex","nextOffset","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","activeSelectionDefaultValues","multiSelectionStacking","ActiveSelection","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","imageData","originalImageData","pipelineState","originalEl","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","glOptions","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","dWidth","dHeight","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","strict","setFilterBackend","backend","imageDefaultValues","srcFromAttribute","minimumScaleTrigger","imageSmoothing","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","getSvgSrc","origFill","filtered","setSrc","minimumScale","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","goodViewbox","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","hasInvalidAncestor","getMultipleNodes","nodeNames","nodeArray","nodeList","getElementsByTagNameNS","parseUseDirectives","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","cloneNode","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","tagArray","getGradientDefs","elList","gradientDefs","getCSSRules","allRules","styleContents","ruleObj","declaration","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","parseSVGDocument","descendants","localClipPaths","elementParser","loadSVGFromString","parser","DOMParser","parseFromString","loadSVGFromURL","xml","responseXML","parsedDoc","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","newAnchorPointInParentPlane","createPolyActionHandler","createPolyControls","calcPathPointPosition","pathObject","commandIndex","movePathPoint","anchorCommand","pathPositionHandler","pathActionHandler","indexFromPrevCommand","previousCommandType","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","createPathControls","isWebGLPipelineState","isPutImageFaster","sourceCanvas","ArrayBuffer","testContext","testPipelineState","performance","now","drawImageTime","putImageDataTime","highPsourceCode","identityFragmentShader","vertexSource","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","filterOptions","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","blendColorDefaultValues","mode","BlendColor","tg","alpha1","uniform4fv","uColor","mask","blendImageDefaultValues","BlendImage","image","TEXTURE1","calculateMatrix","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","enlivedImage","blurDefaultValues","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","brightnessDefaultValues","brightness","Brightness","uBrightness","colorMatrixDefaultValues","colorsOnly","ColorMatrix","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","contrastDefaultValues","contrast","Contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","convoluteDefaultValues","opaque","Convolute","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","gammaDefaultValues","gamma","Gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","grayscaleDefaultValues","Grayscale","uMode","hueRotationDefaultValues","rotation","HueRotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","invertDefaultValues","invert","Invert","uInvert","uAlpha","noiseDefaultValues","noise","Noise","rand","uNoise","uSeed","pixelateDefaultValues","blocksize","Pixelate","_i","_j","uBlocksize","removeColorDefaultValues","useAlpha","RemoveColor","lowC","highC","uLow","uHigh","resizeDefaultValues","resizeType","lanczosLobes","Resize","uTaps","taps","getFilterWindow","tempScale","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","process","u","weight","fX","fY","ratioX","icenter","ratioY","range2X","cacheLanc","range2Y","lanczos","rcpRatioX","rcpRatioY","srcData","destData","destImg","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","saturationDefaultValues","saturation","Saturation","adjust","uSaturation","vibranceDefaultValues","vibrance","Vibrance","amt","uVibrance","StaticCanvasBase","createPNGStream","opts","createJPEGStream","CanvasBase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA,iBAAiB,CAAC;EAAAC,WAAA,GAAA;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbEC,IAAAA,eAAA,oCAc4B,CAAC,CAAA,CAAA;AAE7B;AACF;AACA;AAFEA,IAAAA,eAAA,cAGM,EAAE,CAAA,CAAA;AAER;AACF;AACA;AACA;IAHEA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAKE,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACC,gBAAgB,GAAG,CAAC,CAAA,CAAA;AAAE;AAE/D;AACF;AACA;AACA;AACA;AACA;AALEF,IAAAA,eAAA,6BAMqB,OAAO,CAAA,CAAA;AAE5B;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMoB,IAAI,CAAA,CAAA;AAExB;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMoB,GAAG,CAAA,CAAA;AAEvB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,gCAQwB,KAAK,CAAA,CAAA;AAE7B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,4BAQoB,IAAI,CAAA,CAAA;AAExB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AATEA,IAAAA,eAAA,sBAUc,IAAI,CAAA,CAAA;AAElB;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,8BAOsB,KAAK,CAAA,CAAA;AAE3B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,8BAQsB,KAA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ACdyL,EAAAA,IAAI,EAAE,SAAS;AACfC,EAAAA,OAAO,EAAE,SAAS;AAClBC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,SAAS,EAAE,SAAS;AACpBC,EAAAA,MAAM,EAAE,SAAS;AACjBC,EAAAA,KAAK,EAAE,SAAS;AAChBC,EAAAA,KAAK,EAAE,MAAM;AACbC,EAAAA,UAAU,EAAE,SAAS;AACrBC,EAAAA,MAAM,EAAE,MAAM;AACdC,EAAAA,WAAW,EAAE,SAAA;AACf,CAAC;;ACzJD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,MACpB,kJAAkJ,CAAA;;AAEpJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,MACpB,kKAAkK,CAAA;;AAEpK;AACA;AACA;AACO,MAAMC,KAAK,GAAGA,MAAM,2CAA2C;;AC/GtE;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CAACrU,CAAS,EAAEsU,CAAS,EAAEzV,CAAS,KAAa;EAClE,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;EACA,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,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,eAAA,kBAQU,IAAI,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAVEA,IAAAA,eAAA,qBAWaiJ,KAAK,CAAA,CAAA;AAElB;AACF;AACA;AACA;AACA;AACA;AACA;AANEjJ,IAAAA,eAAA,gBAOQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AANEA,IAAAA,eAAA,YAOI,CAAC,CAAA,CAAA;AAEL;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAXEA,IAAAA,eAAA,kBAYU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,kBAMU,CAAC,CAAA,CAAA;AAEX;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,gBAMQ,CAAC,CAAA,CAAA;AAET;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,qBAMa,CAAC,CAAA,CAAA;AAEd;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,sBAMc,WAAW,CAAA,CAAA;AAEzB;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,yBAMiB,KAAK,CAAA,CAAA;AAGpBS,IAAAA,MAAM,CAACC,MAAM,CAAC,IAAI,EAAE0B,OAAO,CAAC,CAAA;AAC9B,GAAA;;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;EAGE88C,cAAcA,CACZ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KAAK;AAE1B3B,EAAAA,cAAc,EAAE,kBAAkB;AAElC5N,EAAAA,sBAAsB,EAAE,KAAA;AAC1B,CAAC;;ACnPD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMwP,gBAAgB,SACnB56C,cAAY,CAEtB;EAAAjwB,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAAO,SAAA,CAAA,CAAA;AAGE;AAQA;AAUA;AASA;AAKA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAKE;AAKA;AACF;AACA;AACA;AAHEN,IAAAA,eAAA,kBAI0B,EAAE,CAAA,CAAA;AAS5B;AACF;AACA;AACA;AACA;AAJEA,IAAAA,eAAA,0BAKkC,EAAE,CAAA,CAAA;AAEpC;AACF;AACA;AACA;AACA;IAJEA,eAAA,CAAA,IAAA,EAAA,kBAAA,EAAA,KAAA,CAAA,CAAA,CAAA;AAOA;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,4BAMsC,IAAI,CAAA,CAAA;AAE1C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAPEA,IAAAA,eAAA,yBAaW,IAAI,CAAA,CAAA;AAEf;AACF;AACA;AACA;AACA;AACA;AALEA,IAAAA,eAAA,0BAMkB,KAAK,CAAA,CAAA;AAAA,GAAA;EA8BvB,OAAOsw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,aAAa,EAAE,CAACuoH,gBAAgB,CAACD,IAAI,CAAC,CAAA;AACpD,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM37C,MAAM,SAAS67C,QAAU,CAAC;AACrCxoH,EAAAA,aAAaA,GAAG;AACd,IAAA,OAAOA,aAAa,CAAC,IAAI,CAACwsB,UAAU,EAAE,CAAC,CAAA;AACzC,GAAA;EACA67F,eAAeA,CAACC,IAAgB,EAAE;IAChC,OAAO,IAAI,CAACtoH,aAAa,EAAE,CAACqoH,eAAe,CAACC,IAAI,CAAC,CAAA;AACnD,GAAA;EACAC,gBAAgBA,CAACD,IAAiB,EAAE;IAClC,OAAO,IAAI,CAACtoH,aAAa,EAAE,CAACuoH,gBAAgB,CAACD,IAAI,CAAC,CAAA;AACpD,GAAA;AACF;;;;"} \ No newline at end of file +{"version":3,"file":"index.node.mjs","sources":["../src/config.ts","../src/util/internals/console.ts","../src/filters/GLProbes/GLProbe.ts","../src/filters/GLProbes/WebGLProbe.ts","../src/env/browser.ts","../src/env/index.ts","../src/filters/GLProbes/NodeGLProbe.ts","../src/env/node.ts","../src/cache.ts","../src/constants.ts","../src/ClassRegistry.ts","../src/util/animation/AnimationRegistry.ts","../src/Observable.ts","../src/util/internals/removeFromArray.ts","../src/util/misc/cos.ts","../src/util/misc/sin.ts","../src/Point.ts","../src/Collection.ts","../src/CommonMethods.ts","../src/util/animation/AnimationFrameProvider.ts","../src/util/internals/uid.ts","../src/util/misc/dom.ts","../src/util/misc/radiansDegreesConversion.ts","../src/util/misc/matrix.ts","../src/util/misc/objectEnlive.ts","../src/util/misc/pick.ts","../src/color/color_map.ts","../src/color/constants.ts","../src/color/util.ts","../src/color/Color.ts","../src/util/misc/toFixed.ts","../src/util/misc/svgParsing.ts","../src/util/typeAssertions.ts","../src/util/dom_misc.ts","../src/canvas/DOMManagers/util.ts","../src/canvas/DOMManagers/StaticCanvasDOMManager.ts","../src/canvas/StaticCanvasOptions.ts","../src/canvas/StaticCanvas.ts","../src/util/dom_event.ts","../src/util/misc/boundingBoxFromPoints.ts","../src/util/misc/objectTransforms.ts","../src/util/misc/planeChange.ts","../src/controls/fireEvent.ts","../src/util/misc/resolveOrigin.ts","../src/controls/util.ts","../src/controls/drag.ts","../src/shapes/Object/FabricObjectSVGExportMixin.ts","../src/parser/getSvgRegex.ts","../src/parser/constants.ts","../src/util/misc/vectors.ts","../src/Shadow.ts","../src/util/misc/capValue.ts","../src/shapes/Object/defaultValues.ts","../src/util/animation/easing.ts","../src/util/animation/AnimationBase.ts","../src/util/animation/ValueAnimation.ts","../src/util/animation/ArrayAnimation.ts","../src/util/animation/ColorAnimation.ts","../src/util/animation/animate.ts","../src/Intersection.ts","../src/shapes/Object/ObjectGeometry.ts","../src/shapes/Object/Object.ts","../src/controls/wrapWithFireEvent.ts","../src/controls/wrapWithFixedAnchor.ts","../src/controls/changeWidth.ts","../src/controls/controlRendering.ts","../src/controls/Control.ts","../src/controls/rotate.ts","../src/controls/scale.ts","../src/controls/skew.ts","../src/controls/scaleSkew.ts","../src/controls/commonControls.ts","../src/shapes/Object/InteractiveObject.ts","../src/util/applyMixins.ts","../src/shapes/Object/FabricObject.ts","../src/util/misc/isTransparent.ts","../src/util/misc/rotatePoint.ts","../src/util/internals/findRight.ts","../src/util/misc/projectStroke/StrokeProjectionsBase.ts","../src/util/misc/projectStroke/StrokeLineJoinProjections.ts","../src/util/misc/projectStroke/StrokeLineCapProjections.ts","../src/util/misc/projectStroke/index.ts","../src/util/internals/cloneStyles.ts","../src/util/lang_string.ts","../src/util/misc/textStyles.ts","../src/parser/attributes.ts","../src/parser/selectorMatches.ts","../src/parser/doesSomeParentMatch.ts","../src/parser/elementMatchesRule.ts","../src/parser/getGlobalStylesForElement.ts","../src/parser/normalizeAttr.ts","../src/util/internals/cleanupSvgAttribute.ts","../src/parser/parseTransformAttribute.ts","../src/parser/normalizeValue.ts","../src/parser/parseFontDeclaration.ts","../src/parser/parseStyleObject.ts","../src/parser/parseStyleString.ts","../src/parser/parseStyleAttribute.ts","../src/parser/setStrokeFillOpacity.ts","../src/parser/parseAttributes.ts","../src/shapes/Rect.ts","../src/LayoutManager/constants.ts","../src/LayoutManager/LayoutStrategies/utils.ts","../src/LayoutManager/LayoutStrategies/LayoutStrategy.ts","../src/LayoutManager/LayoutStrategies/FitContentLayout.ts","../src/LayoutManager/LayoutManager.ts","../src/shapes/Group.ts","../src/util/misc/groupSVGElements.ts","../src/util/misc/findScaleTo.ts","../src/util/path/regex.ts","../src/util/path/index.ts","../src/util/dom_style.ts","../src/util/misc/mergeClipPaths.ts","../src/util/internals/getRandomInt.ts","../src/util/internals/dom_request.ts","../src/util/transform_matrix_removal.ts","../src/canvas/DOMManagers/CanvasDOMManager.ts","../src/canvas/CanvasOptions.ts","../src/canvas/SelectableCanvas.ts","../src/canvas/TextEditingManager.ts","../src/canvas/Canvas.ts","../src/gradient/constants.ts","../src/util/internals/ifNaN.ts","../src/parser/percent.ts","../src/gradient/parser/parseColorStops.ts","../src/gradient/parser/misc.ts","../src/gradient/parser/parseCoords.ts","../src/gradient/Gradient.ts","../src/Pattern/Pattern.ts","../src/brushes/BaseBrush.ts","../src/shapes/Path.ts","../src/brushes/PencilBrush.ts","../src/shapes/Circle.ts","../src/brushes/CircleBrush.ts","../src/brushes/SprayBrush.ts","../src/brushes/PatternBrush.ts","../src/shapes/Line.ts","../src/shapes/Triangle.ts","../src/shapes/Ellipse.ts","../src/parser/parsePointsAttribute.ts","../src/shapes/Polyline.ts","../src/shapes/Polygon.ts","../src/shapes/Text/constants.ts","../src/shapes/Text/StyledText.ts","../src/shapes/Text/TextSVGExportMixin.ts","../src/shapes/Text/Text.ts","../src/shapes/IText/DraggableTextDelegate.ts","../src/shapes/IText/ITextBehavior.ts","../src/shapes/IText/ITextKeyBehavior.ts","../src/shapes/IText/ITextClickBehavior.ts","../src/shapes/IText/constants.ts","../src/shapes/IText/IText.ts","../src/shapes/Textbox.ts","../src/LayoutManager/LayoutStrategies/ClipPathLayout.ts","../src/LayoutManager/LayoutStrategies/FixedLayout.ts","../src/LayoutManager/ActiveSelectionLayoutManager.ts","../src/shapes/ActiveSelection.ts","../src/filters/Canvas2dFilterBackend.ts","../src/filters/WebGLFilterBackend.ts","../src/filters/FilterBackend.ts","../src/shapes/Image.ts","../src/parser/applyViewboxTransform.ts","../src/parser/getTagName.ts","../src/parser/hasInvalidAncestor.ts","../src/parser/getMultipleNodes.ts","../src/parser/parseUseDirectives.ts","../src/parser/recursivelyParseGradientsXlink.ts","../src/parser/getGradientDefs.ts","../src/parser/getCSSRules.ts","../src/parser/elements_parser.ts","../src/parser/parseSVGDocument.ts","../src/parser/loadSVGFromString.ts","../src/parser/loadSVGFromURL.ts","../src/controls/polyControl.ts","../src/controls/pathControl.ts","../src/filters/utils.ts","../src/filters/shaders/baseFilter.ts","../src/filters/BaseFilter.ts","../src/filters/shaders/blendColor.ts","../src/filters/BlendColor.ts","../src/filters/shaders/blendImage.ts","../src/filters/BlendImage.ts","../src/filters/shaders/blur.ts","../src/filters/Blur.ts","../src/filters/shaders/brightness.ts","../src/filters/Brightness.ts","../src/filters/shaders/colorMatrix.ts","../src/filters/ColorMatrix.ts","../src/filters/ColorMatrixFilters.ts","../src/filters/Composed.ts","../src/filters/shaders/constrast.ts","../src/filters/Contrast.ts","../src/filters/shaders/convolute.ts","../src/filters/Convolute.ts","../src/filters/shaders/gamma.ts","../src/filters/Gamma.ts","../src/filters/shaders/grayscale.ts","../src/filters/Grayscale.ts","../src/filters/HueRotation.ts","../src/filters/shaders/invert.ts","../src/filters/Invert.ts","../src/filters/shaders/noise.ts","../src/filters/Noise.ts","../src/filters/shaders/pixelate.ts","../src/filters/Pixelate.ts","../src/filters/shaders/removeColor.ts","../src/filters/RemoveColor.ts","../src/filters/Resize.ts","../src/filters/shaders/saturation.ts","../src/filters/Saturation.ts","../src/filters/shaders/vibrance.ts","../src/filters/Vibrance.ts","../index.node.ts"],"sourcesContent":["export type TConfiguration = Partial;\n\nclass BaseConfiguration {\n /**\n * Browser-specific constant to adjust CanvasRenderingContext2D.shadowBlur value,\n * which is unitless and not rendered equally across browsers.\n *\n * Values that work quite well (as of October 2017) are:\n * - Chrome: 1.5\n * - Edge: 1.75\n * - Firefox: 0.9\n * - Safari: 0.95\n *\n * @since 2.0.0\n * @type Number\n * @default 1\n */\n browserShadowBlurConstant = 1;\n\n /**\n * Pixel per Inch as a default value set to 96. Can be changed for more realistic conversion.\n */\n DPI = 96;\n\n /**\n * Device Pixel Ratio\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n */\n devicePixelRatio =\n typeof window !== 'undefined' ? window.devicePixelRatio : 1; // eslint-disable-line no-restricted-globals\n\n /**\n * Pixel limit for cache canvases. 1Mpx , 4Mpx should be fine.\n * @since 1.7.14\n * @type Number\n * @default\n */\n perfLimitSizeTotal = 2097152;\n\n /**\n * Pixel limit for cache canvases width or height. IE fixes the maximum at 5000\n * @since 1.7.14\n * @type Number\n * @default\n */\n maxCacheSideLimit = 4096;\n\n /**\n * Lowest pixel limit for cache canvases, set at 256PX\n * @since 1.7.14\n * @type Number\n * @default\n */\n minCacheSideLimit = 256;\n\n /**\n * When 'true', style information is not retained when copy/pasting text, making\n * pasted text use destination style.\n * Defaults to 'false'.\n * @type Boolean\n * @default\n * @deprecated\n */\n disableStyleCopyPaste = false;\n\n /**\n * Enable webgl for filtering picture is available\n * A filtering backend will be initialized, this will both take memory and\n * time since a default 2048x2048 canvas will be created for the gl context\n * @since 2.0.0\n * @type Boolean\n * @default\n */\n enableGLFiltering = true;\n\n /**\n * if webgl is enabled and available, textureSize will determine the size\n * of the canvas backend\n *\n * In order to support old hardware set to `2048` to avoid OOM\n *\n * @since 2.0.0\n * @type Number\n * @default\n */\n textureSize = 4096;\n\n /**\n * Skip performance testing of setupGLContext and force the use of putImageData that seems to be the one that works best on\n * Chrome + old hardware. if your users are experiencing empty images after filtering you may try to force this to true\n * this has to be set before instantiating the filtering backend ( before filtering the first image )\n * @type Boolean\n * @default false\n */\n forceGLPutImageData = false;\n\n /**\n * If disabled boundsOfCurveCache is not used. For apps that make heavy usage of pencil drawing probably disabling it is better\n * With the standard behaviour of fabric to translate all curves in absolute commands and by not subtracting the starting point from\n * the curve is very hard to hit any cache.\n * Enable only if you know why it could be useful.\n * Candidate for removal/simplification\n * @default false\n */\n cachesBoundsOfCurve = false;\n\n /**\n * Map of font files\n * Map of font files\n */\n fontPaths: Record = {};\n\n /**\n * Defines the number of fraction digits to use when serializing object values.\n * Used in exporting methods (`toObject`, `toJSON`, `toSVG`)\n * You can use it to increase/decrease precision of such values like left, top, scaleX, scaleY, etc.\n */\n NUM_FRACTION_DIGITS = 4;\n}\n\nexport class Configuration extends BaseConfiguration {\n constructor(config?: TConfiguration) {\n super();\n this.configure(config);\n }\n\n configure(config: TConfiguration = {}) {\n Object.assign(this, config);\n }\n\n /**\n * Map of font files\n */\n addFonts(\n paths: Record = {},\n ) {\n this.fontPaths = {\n ...this.fontPaths,\n ...paths,\n };\n }\n\n removeFonts(fontFamilys: string[] = []) {\n fontFamilys.forEach((fontFamily) => {\n delete this.fontPaths[fontFamily];\n });\n }\n\n clearFonts() {\n this.fontPaths = {};\n }\n\n restoreDefaults(keys?: (keyof T)[]) {\n const defaults = new BaseConfiguration() as T;\n const config =\n keys?.reduce((acc, key) => {\n acc[key] = defaults[key];\n return acc;\n }, {} as T) || defaults;\n this.configure(config);\n }\n}\n\nexport const config = new Configuration();\n","export const log = (\n severity: 'log' | 'warn' | 'error',\n ...optionalParams: any[]\n) =>\n // eslint-disable-next-line no-restricted-syntax\n console[severity]('fabric', ...optionalParams);\n\nexport class FabricError extends Error {\n constructor(message?: string, options?: ErrorOptions) {\n super(`fabric: ${message}`, options);\n }\n}\n\nexport class SignalAbortedError extends FabricError {\n constructor(context: string) {\n super(`${context} 'options.signal' is in 'aborted' state`);\n }\n}\n","export type GLPrecision = 'lowp' | 'mediump' | 'highp';\n\nexport abstract class GLProbe {\n declare GLPrecision: GLPrecision | undefined;\n abstract queryWebGL(canvas: HTMLCanvasElement): void;\n abstract isSupported(textureSize: number): boolean;\n}\n","import { log } from '../../util/internals/console';\nimport { GLProbe } from './GLProbe';\nimport type { GLPrecision } from './GLProbe';\n\n/**\n * Lazy initialize WebGL constants\n */\nexport class WebGLProbe extends GLProbe {\n declare maxTextureSize?: number;\n\n /**\n * Tests if webgl supports certain precision\n * @param {WebGL} Canvas WebGL context to test on\n * @param {GLPrecision} Precision to test can be any of following\n * @returns {Boolean} Whether the user's browser WebGL supports given precision.\n */\n private testPrecision(\n gl: WebGLRenderingContext,\n precision: GLPrecision,\n ): boolean {\n const fragmentSource = `precision ${precision} float;\\nvoid main(){}`;\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n if (!fragmentShader) {\n return false;\n }\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n return !!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS);\n }\n\n /**\n * query browser for WebGL\n */\n queryWebGL(canvas: HTMLCanvasElement) {\n const gl = canvas.getContext('webgl');\n if (gl) {\n this.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);\n this.GLPrecision = (['highp', 'mediump', 'lowp'] as const).find(\n (precision) => this.testPrecision(gl, precision),\n );\n gl.getExtension('WEBGL_lose_context')!.loseContext();\n log('log', `WebGL: max texture size ${this.maxTextureSize}`);\n }\n }\n\n isSupported(textureSize: number) {\n return !!this.maxTextureSize && this.maxTextureSize >= textureSize;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport { WebGLProbe } from '../filters/GLProbes/WebGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst copyPasteData: TCopyPasteData = {};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document,\n window,\n isTouchSupported:\n 'ontouchstart' in window ||\n 'ontouchstart' in document ||\n (window && window.navigator && window.navigator.maxTouchPoints > 0),\n WebGLProbe: new WebGLProbe(),\n dispose() {\n // noop\n },\n copyPasteData,\n };\n};\n","/**\n * This file is consumed by fabric.\n * The `./node` and `./browser` files define the env variable that is used by this module.\n * The `./browser` module is defined to be the default env and doesn't set the env at all.\n * This is done in order to support isomorphic usage for browser and node applications\n * since window and document aren't defined at time of import in SSR, we can't set env so we avoid it by deferring to the default env.\n */\n\nimport { config } from '../config';\nimport { getEnv as getBrowserEnv } from './browser';\nimport type { TFabricEnv } from './types';\nimport type { DOMWindow } from 'jsdom';\n\nlet env: TFabricEnv;\n\n/**\n * Sets the environment variables used by fabric.\\\n * This is exposed for special cases, such as configuring a test environment, and should be used with care.\n *\n * **CAUTION**: Must be called before using the package.\n *\n * @example\n * Passing `window` and `document` objects to fabric (in case they are mocked or something)\n * import { getEnv, setEnv } from 'fabric';\n * // we want fabric to use the `window` and `document` objects exposed by the environment we are running in.\n * setEnv({ ...getEnv(), window, document });\n * // done with setup, using fabric is now safe\n */\nexport const setEnv = (value: TFabricEnv) => {\n env = value;\n};\n\n/**\n * In order to support SSR we **MUST** access the browser env only after the window has loaded\n */\nexport const getEnv = () => env || (env = getBrowserEnv());\n\nexport const getFabricDocument = (): Document => getEnv().document;\n\nexport const getFabricWindow = (): (Window & typeof globalThis) | DOMWindow =>\n getEnv().window;\n\n/**\n * @returns the config value if defined, fallbacks to the environment value\n */\nexport const getDevicePixelRatio = () =>\n Math.max(config.devicePixelRatio ?? getFabricWindow().devicePixelRatio, 1);\n","import { GLProbe } from './GLProbe';\n\n/**\n * @todo GL rendering in node is possible:\n * - https://github.com/stackgl/headless-gl\n * - https://github.com/akira-cn/node-canvas-webgl\n */\nexport class NodeGLProbe extends GLProbe {\n queryWebGL() {\n // noop\n }\n isSupported() {\n return false;\n }\n}\n","/* eslint-disable no-restricted-globals */\nimport type { Canvas as NodeCanvas } from 'canvas';\nimport { JSDOM } from 'jsdom';\n// @ts-expect-error internal import\nimport utils from 'jsdom/lib/jsdom/living/generated/utils.js';\nimport { NodeGLProbe } from '../filters/GLProbes/NodeGLProbe';\nimport type { TCopyPasteData, TFabricEnv } from './types';\n\nconst { implForWrapper: jsdomImplForWrapper } = utils;\n\nconst copyPasteData: TCopyPasteData = {};\n\nconst { window: JSDOMWindow } = new JSDOM(\n decodeURIComponent(\n '%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E',\n ),\n {\n resources: 'usable',\n // needed for `requestAnimationFrame`\n pretendToBeVisual: true,\n },\n);\n\nexport const getNodeCanvas = (canvasEl: HTMLCanvasElement) => {\n const impl = jsdomImplForWrapper(canvasEl);\n return (impl._canvas || impl._image) as NodeCanvas;\n};\n\nexport const dispose = (element: Element) => {\n const impl = jsdomImplForWrapper(element);\n if (impl) {\n impl._image = null;\n impl._canvas = null;\n // unsure if necessary\n impl._currentSrc = null;\n impl._attributes = null;\n impl._classList = null;\n }\n};\n\nexport const getEnv = (): TFabricEnv => {\n return {\n document: JSDOMWindow.document,\n window: JSDOMWindow,\n isTouchSupported: false,\n WebGLProbe: new NodeGLProbe(),\n dispose,\n copyPasteData,\n };\n};\n","import { config } from './config';\nimport type { TRectBounds } from './typedefs';\n\nexport class Cache {\n /**\n * Cache of widths of chars in text rendering.\n */\n charWidthsCache: Record<\n /** fontFamily */ string,\n Record<\n /** fontStyleCacheKey */ string,\n Record\n >\n > = {};\n\n /**\n * @return {Object} reference to cache\n */\n getFontCache({\n fontFamily,\n fontStyle,\n fontWeight,\n }: {\n fontFamily: string;\n fontStyle: string;\n fontWeight: string | number;\n }) {\n fontFamily = fontFamily.toLowerCase();\n if (!this.charWidthsCache[fontFamily]) {\n this.charWidthsCache[fontFamily] = {};\n }\n const fontCache = this.charWidthsCache[fontFamily];\n const cacheKey = `${fontStyle.toLowerCase()}_${(\n fontWeight + ''\n ).toLowerCase()}`;\n if (!fontCache[cacheKey]) {\n fontCache[cacheKey] = {};\n }\n return fontCache[cacheKey];\n }\n\n /**\n * Clear char widths cache for the given font family or all the cache if no\n * fontFamily is specified.\n * Use it if you know you are loading fonts in a lazy way and you are not waiting\n * for custom fonts to load properly when adding text objects to the canvas.\n * If a text object is added when its own font is not loaded yet, you will get wrong\n * measurement and so wrong bounding boxes.\n * After the font cache is cleared, either change the textObject text content or call\n * initDimensions() to trigger a recalculation\n * @param {String} [fontFamily] font family to clear\n */\n clearFontCache(fontFamily?: string) {\n fontFamily = (fontFamily || '').toLowerCase();\n if (!fontFamily) {\n this.charWidthsCache = {};\n } else if (this.charWidthsCache[fontFamily]) {\n delete this.charWidthsCache[fontFamily];\n }\n }\n\n /**\n * Given current aspect ratio, determines the max width and height that can\n * respect the total allowed area for the cache.\n * @param {number} ar aspect ratio\n * @return {number[]} Limited dimensions X and Y\n */\n limitDimsByArea(ar: number) {\n const { perfLimitSizeTotal } = config;\n const roughWidth = Math.sqrt(perfLimitSizeTotal * ar);\n // we are not returning a point on purpose, to avoid circular dependencies\n // this is an internal utility\n return [\n Math.floor(roughWidth),\n Math.floor(perfLimitSizeTotal / roughWidth),\n ];\n }\n\n /**\n * This object keeps the results of the boundsOfCurve calculation mapped by the joined arguments necessary to calculate it.\n * It does speed up calculation, if you parse and add always the same paths, but in case of heavy usage of freedrawing\n * you do not get any speed benefit and you get a big object in memory.\n * The object was a private variable before, while now is appended to the lib so that you have access to it and you\n * can eventually clear it.\n * It was an internal variable, is accessible since version 2.3.4\n */\n boundsOfCurveCache: Record = {};\n}\n\nexport const cache = new Cache();\n","import type { TMat2D } from './typedefs';\n// use this syntax so babel plugin see this import here\nimport { version } from '../package.json';\n\nexport const VERSION = version;\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport function noop() {}\n\nexport const halfPI = Math.PI / 2;\nexport const twoMathPi = Math.PI * 2;\nexport const PiBy180 = Math.PI / 180;\n\nexport const iMatrix = Object.freeze([1, 0, 0, 1, 0, 0]) as TMat2D;\nexport const DEFAULT_SVG_FONT_SIZE = 16;\nexport const ALIASING_LIMIT = 2;\n\n/* \"magic number\" for bezier approximations of arcs (http://itc.ktu.lt/itc354/Riskus354.pdf) */\nexport const kRect = 1 - 0.5522847498;\n\nexport const CENTER = 'center';\nexport const LEFT = 'left';\nexport const TOP = 'top';\nexport const BOTTOM = 'bottom';\nexport const RIGHT = 'right';\nexport const NONE = 'none';\n\nexport const reNewline = /\\r?\\n/;\n\nexport const MOVING = 'moving';\nexport const SCALING = 'scaling';\nexport const ROTATING = 'rotating';\nexport const ROTATE = 'rotate';\nexport const SKEWING = 'skewing';\nexport const RESIZING = 'resizing';\nexport const MODIFY_POLY = 'modifyPoly';\nexport const MODIFY_PATH = 'modifyPath';\nexport const CHANGED = 'changed';\nexport const SCALE = 'scale';\nexport const SCALE_X = 'scaleX';\nexport const SCALE_Y = 'scaleY';\nexport const SKEW_X = 'skewX';\nexport const SKEW_Y = 'skewY';\nexport const FILL = 'fill';\nexport const STROKE = 'stroke';\nexport const MODIFIED = 'modified';\n","import { FabricError } from './util/internals/console';\n\n/*\n * This Map connects the objects type value with their\n * class implementation. It used from any object to understand which are\n * the classes to enlive when requesting a object.type = 'path' for example.\n * Objects uses it for clipPath, Canvas uses it for everything.\n * This is necessary for generic code to run and enlive instances from serialized representation.\n * You can customize which classes get enlived from SVG parsing using this classRegistry.\n * The Registry start empty and gets filled in depending which files you import.\n * If you want to be able to parse arbitrary SVGs or JSON representation of canvases, coming from\n * different sources you will need to import all fabric because you may need all classes.\n */\n\nexport const JSON = 'json';\nexport const SVG = 'svg';\n\nexport class ClassRegistry {\n declare [JSON]: Map;\n declare [SVG]: Map;\n\n constructor() {\n this[JSON] = new Map();\n this[SVG] = new Map();\n }\n\n has(classType: string): boolean {\n return this[JSON].has(classType);\n }\n\n getClass(classType: string): T {\n const constructor = this[JSON].get(classType);\n if (!constructor) {\n throw new FabricError(`No class registered for ${classType}`);\n }\n return constructor;\n }\n\n setClass(classConstructor: any, classType?: string) {\n if (classType) {\n this[JSON].set(classType, classConstructor);\n } else {\n this[JSON].set(classConstructor.type, classConstructor);\n // legacy\n // @TODO: needs to be removed in fabric 7 or 8\n this[JSON].set(classConstructor.type.toLowerCase(), classConstructor);\n }\n }\n\n getSVGClass(SVGTagName: string): any {\n return this[SVG].get(SVGTagName);\n }\n\n setSVGClass(classConstructor: any, SVGTagName?: string) {\n this[SVG].set(\n SVGTagName ?? classConstructor.type.toLowerCase(),\n classConstructor,\n );\n }\n}\n\nexport const classRegistry = new ClassRegistry();\n","import type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type { AnimationBase } from './AnimationBase';\n\n/**\n * Array holding all running animations\n */\nclass AnimationRegistry extends Array {\n /**\n * Remove a single animation using an animation context\n * @param {AnimationBase} context\n */\n remove(context: AnimationBase) {\n const index = this.indexOf(context);\n index > -1 && this.splice(index, 1);\n }\n\n /**\n * Cancel all running animations on the next frame\n */\n cancelAll() {\n const animations = this.splice(0);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations attached to a canvas on the next frame\n * @param {StaticCanvas} canvas\n */\n cancelByCanvas(canvas: StaticCanvas) {\n if (!canvas) {\n return [];\n }\n const animations = this.filter(\n (animation) =>\n animation.target === canvas ||\n (typeof animation.target === 'object' &&\n (animation.target as FabricObject)?.canvas === canvas),\n );\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n\n /**\n * Cancel all running animations for target on the next frame\n * @param target\n */\n cancelByTarget(target: AnimationBase['target']) {\n if (!target) {\n return [];\n }\n const animations = this.filter((animation) => animation.target === target);\n animations.forEach((animation) => animation.abort());\n return animations;\n }\n}\n\nexport const runningAnimations = new AnimationRegistry();\n","export type TEventCallback = (options: T) => any;\n\ntype EventRegistryObject = {\n [K in keyof E]?: TEventCallback;\n};\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#events}\n * @see {@link http://fabricjs.com/events|Events demo}\n */\nexport class Observable {\n private __eventListeners: Record =\n {} as Record;\n\n /**\n * Observes specified event\n * @alias on\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n on(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n on(handlers: EventRegistryObject): VoidFunction;\n on(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (!this.__eventListeners) {\n this.__eventListeners = {} as Record;\n }\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this.on(eventName as K, handler as TEventCallback);\n });\n return () => this.off(arg0);\n } else if (handler) {\n const eventName = arg0;\n if (!this.__eventListeners[eventName]) {\n this.__eventListeners[eventName] = [];\n }\n this.__eventListeners[eventName].push(handler);\n return () => this.off(eventName, handler);\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * Observes specified event **once**\n * @alias once\n * @param {string} eventName Event name (eg. 'after:render')\n * @param {EventRegistryObject} handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n * @param {Function} handler Function that receives a notification when an event of the specified type occurs\n * @return {Function} disposer\n */\n once(\n eventName: K,\n handler: TEventCallback,\n ): VoidFunction;\n once(handlers: EventRegistryObject): VoidFunction;\n once(\n arg0: K | EventRegistryObject,\n handler?: TEventCallback,\n ): VoidFunction {\n if (typeof arg0 === 'object') {\n // one object with key/value pairs was passed\n const disposers: VoidFunction[] = [];\n Object.entries(arg0).forEach(([eventName, handler]) => {\n disposers.push(this.once(eventName as K, handler as TEventCallback));\n });\n return () => disposers.forEach((d) => d());\n } else if (handler) {\n const disposer = this.on(\n arg0,\n function onceHandler(this: Observable, ...args) {\n handler.call(this, ...args);\n disposer();\n },\n );\n return disposer;\n } else {\n // noop\n return () => false;\n }\n }\n\n /**\n * @private\n * @param {string} eventName\n * @param {Function} [handler]\n */\n private _removeEventListener(\n eventName: K,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners[eventName]) {\n return;\n }\n\n if (handler) {\n const eventListener = this.__eventListeners[eventName];\n const index = eventListener.indexOf(handler);\n index > -1 && eventListener.splice(index, 1);\n } else {\n this.__eventListeners[eventName] = [];\n }\n }\n\n /**\n * Unsubscribe all event listeners for eventname.\n * Do not use this pattern. You could kill internal fabricJS events.\n * We know we should have protected events for internal flows, but we don't have yet\n * @deprecated\n * @param {string} eventName event name (eg. 'after:render')\n */\n off(eventName: K): void;\n /**\n * unsubscribe an event listener\n * @param {string} eventName event name (eg. 'after:render')\n * @param {TEventCallback} handler event listener to unsubscribe\n */\n off(eventName: K, handler: TEventCallback): void;\n /**\n * unsubscribe event listeners\n * @param handlers handlers key/value pairs (eg. {'after:render': handler, 'selection:cleared': handler})\n */\n off(handlers: EventRegistryObject): void;\n /**\n * unsubscribe all event listeners\n */\n off(): void;\n off(\n arg0?: K | EventRegistryObject,\n handler?: TEventCallback,\n ) {\n if (!this.__eventListeners) {\n return;\n }\n\n // remove all key/value pairs (event name -> event handler)\n if (typeof arg0 === 'undefined') {\n for (const eventName in this.__eventListeners) {\n this._removeEventListener(eventName);\n }\n }\n // one object with key/value pairs was passed\n else if (typeof arg0 === 'object') {\n Object.entries(arg0).forEach(([eventName, handler]) => {\n this._removeEventListener(eventName as K, handler as TEventCallback);\n });\n } else {\n this._removeEventListener(arg0, handler);\n }\n }\n\n /**\n * Fires event with an optional options object\n * @param {String} eventName Event name to fire\n * @param {Object} [options] Options object\n */\n fire(eventName: K, options?: EventSpec[K]) {\n if (!this.__eventListeners) {\n return;\n }\n\n const listenersForEvent = this.__eventListeners[eventName]?.concat();\n if (listenersForEvent) {\n for (let i = 0; i < listenersForEvent.length; i++) {\n listenersForEvent[i].call(this, options || {});\n }\n }\n }\n}\n","/**\n * Removes value from an array.\n * Presence of value (and its position in an array) is determined via `Array.prototype.indexOf`\n * @param {Array} array\n * @param {*} value\n * @return {Array} original array\n */\nexport const removeFromArray = (array: T[], value: T): T[] => {\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array;\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the cosin value for angle.\n */\nexport const cos = (angle: TRadian): number => {\n if (angle === 0) {\n return 1;\n }\n const angleSlice = Math.abs(angle) / halfPI;\n switch (angleSlice) {\n case 1:\n case 3:\n return 0;\n case 2:\n return -1;\n }\n return Math.cos(angle);\n};\n","import type { TRadian } from '../../typedefs';\nimport { halfPI } from '../../constants';\n\n/**\n * Calculate the cos of an angle, avoiding returning floats for known results\n * This function is here just to avoid getting 0.999999999999999 when dealing\n * with numbers that are really 1 or 0.\n * @param {TRadian} angle the angle\n * @return {Number} the sin value for angle.\n */\nexport const sin = (angle: TRadian): number => {\n if (angle === 0) {\n return 0;\n }\n const angleSlice = angle / halfPI;\n const value = Math.sign(angle);\n switch (angleSlice) {\n case 1:\n return value;\n case 2:\n return 0;\n case 3:\n return -value;\n }\n return Math.sin(angle);\n};\n","import type { TMat2D, TRadian } from './typedefs';\nimport { cos } from './util/misc/cos';\nimport { sin } from './util/misc/sin';\n\nexport interface XY {\n x: number;\n y: number;\n}\n\n/**\n * Adaptation of work of Kevin Lindsey(kevin@kevlindev.com)\n */\nexport class Point implements XY {\n declare x: number;\n\n declare y: number;\n\n constructor();\n constructor(x: number, y: number);\n constructor(point?: XY);\n constructor(arg0: number | XY = 0, y = 0) {\n if (typeof arg0 === 'object') {\n this.x = arg0.x;\n this.y = arg0.y;\n } else {\n this.x = arg0;\n this.y = y;\n }\n }\n\n /**\n * Adds another point to this one and returns another one\n * @param {XY} that\n * @return {Point} new Point instance with added values\n */\n add(that: XY): Point {\n return new Point(this.x + that.x, this.y + that.y);\n }\n\n /**\n * Adds another point to this one\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n addEquals(that: XY): Point {\n this.x += that.x;\n this.y += that.y;\n return this;\n }\n\n /**\n * Adds value to this point and returns a new one\n * @param {Number} scalar\n * @return {Point} new Point with added value\n */\n scalarAdd(scalar: number): Point {\n return new Point(this.x + scalar, this.y + scalar);\n }\n\n /**\n * Adds value to this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarAddEquals(scalar: number): Point {\n this.x += scalar;\n this.y += scalar;\n return this;\n }\n\n /**\n * Subtracts another point from this point and returns a new one\n * @param {XY} that\n * @return {Point} new Point object with subtracted values\n */\n subtract(that: XY): Point {\n return new Point(this.x - that.x, this.y - that.y);\n }\n\n /**\n * Subtracts another point from this point\n * @param {XY} that\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n subtractEquals(that: XY): Point {\n this.x -= that.x;\n this.y -= that.y;\n return this;\n }\n\n /**\n * Subtracts value from this point and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarSubtract(scalar: number): Point {\n return new Point(this.x - scalar, this.y - scalar);\n }\n\n /**\n * Subtracts value from this point\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarSubtractEquals(scalar: number): Point {\n this.x -= scalar;\n this.y -= scalar;\n return this;\n }\n\n /**\n * Multiplies this point by another value and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n multiply(that: XY): Point {\n return new Point(this.x * that.x, this.y * that.y);\n }\n\n /**\n * Multiplies this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarMultiply(scalar: number): Point {\n return new Point(this.x * scalar, this.y * scalar);\n }\n\n /**\n * Multiplies this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarMultiplyEquals(scalar: number): Point {\n this.x *= scalar;\n this.y *= scalar;\n return this;\n }\n\n /**\n * Divides this point by another and returns a new one\n * @param {XY} that\n * @return {Point}\n */\n divide(that: XY): Point {\n return new Point(this.x / that.x, this.y / that.y);\n }\n\n /**\n * Divides this point by a value and returns a new one\n * @param {Number} scalar\n * @return {Point}\n */\n scalarDivide(scalar: number): Point {\n return new Point(this.x / scalar, this.y / scalar);\n }\n\n /**\n * Divides this point by a value\n * @param {Number} scalar\n * @return {Point} thisArg\n * @chainable\n * @deprecated\n */\n scalarDivideEquals(scalar: number): Point {\n this.x /= scalar;\n this.y /= scalar;\n return this;\n }\n\n /**\n * Returns true if this point is equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n eq(that: XY): boolean {\n return this.x === that.x && this.y === that.y;\n }\n\n /**\n * Returns true if this point is less than another one\n * @param {XY} that\n * @return {Boolean}\n */\n lt(that: XY): boolean {\n return this.x < that.x && this.y < that.y;\n }\n\n /**\n * Returns true if this point is less than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n lte(that: XY): boolean {\n return this.x <= that.x && this.y <= that.y;\n }\n\n /**\n\n * Returns true if this point is greater another one\n * @param {XY} that\n * @return {Boolean}\n */\n gt(that: XY): boolean {\n return this.x > that.x && this.y > that.y;\n }\n\n /**\n * Returns true if this point is greater than or equal to another one\n * @param {XY} that\n * @return {Boolean}\n */\n gte(that: XY): boolean {\n return this.x >= that.x && this.y >= that.y;\n }\n\n /**\n * Returns new point which is the result of linear interpolation with this one and another one\n * @param {XY} that\n * @param {Number} t , position of interpolation, between 0 and 1 default 0.5\n * @return {Point}\n */\n lerp(that: XY, t = 0.5): Point {\n t = Math.max(Math.min(1, t), 0);\n return new Point(\n this.x + (that.x - this.x) * t,\n this.y + (that.y - this.y) * t,\n );\n }\n\n /**\n * Returns distance from this point and another one\n * @param {XY} that\n * @return {Number}\n */\n distanceFrom(that: XY): number {\n const dx = this.x - that.x,\n dy = this.y - that.y;\n return Math.sqrt(dx * dx + dy * dy);\n }\n\n /**\n * Returns the point between this point and another one\n * @param {XY} that\n * @return {Point}\n */\n midPointFrom(that: XY): Point {\n return this.lerp(that);\n }\n\n /**\n * Returns a new point which is the min of this and another one\n * @param {XY} that\n * @return {Point}\n */\n min(that: XY): Point {\n return new Point(Math.min(this.x, that.x), Math.min(this.y, that.y));\n }\n\n /**\n * Returns a new point which is the max of this and another one\n * @param {XY} that\n * @return {Point}\n */\n max(that: XY): Point {\n return new Point(Math.max(this.x, that.x), Math.max(this.y, that.y));\n }\n\n /**\n * Returns string representation of this point\n * @return {String}\n */\n toString(): string {\n return `${this.x},${this.y}`;\n }\n\n /**\n * Sets x/y of this point\n * @param {Number} x\n * @param {Number} y\n * @chainable\n */\n setXY(x: number, y: number) {\n this.x = x;\n this.y = y;\n return this;\n }\n\n /**\n * Sets x of this point\n * @param {Number} x\n * @chainable\n */\n setX(x: number) {\n this.x = x;\n return this;\n }\n\n /**\n * Sets y of this point\n * @param {Number} y\n * @chainable\n */\n setY(y: number) {\n this.y = y;\n return this;\n }\n\n /**\n * Sets x/y of this point from another point\n * @param {XY} that\n * @chainable\n */\n setFromPoint(that: XY) {\n this.x = that.x;\n this.y = that.y;\n return this;\n }\n\n /**\n * Swaps x/y of this point and another point\n * @param {XY} that\n */\n swap(that: XY) {\n const x = this.x,\n y = this.y;\n this.x = that.x;\n this.y = that.y;\n that.x = x;\n that.y = y;\n }\n\n /**\n * return a cloned instance of the point\n * @return {Point}\n */\n clone(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Rotates `point` around `origin` with `radians`\n * @static\n * @memberOf fabric.util\n * @param {XY} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\n rotate(radians: TRadian, origin: XY = ZERO): Point {\n // TODO benchmark and verify the add and subtract how much cost\n // and then in case early return if no origin is passed\n const sinus = sin(radians),\n cosinus = cos(radians);\n const p = this.subtract(origin);\n const rotated = new Point(\n p.x * cosinus - p.y * sinus,\n p.x * sinus + p.y * cosinus,\n );\n return rotated.add(origin);\n }\n\n /**\n * Apply transform t to point p\n * @static\n * @memberOf fabric.util\n * @param {TMat2D} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\n transform(t: TMat2D, ignoreOffset = false): Point {\n return new Point(\n t[0] * this.x + t[2] * this.y + (ignoreOffset ? 0 : t[4]),\n t[1] * this.x + t[3] * this.y + (ignoreOffset ? 0 : t[5]),\n );\n }\n}\n\nexport const ZERO = new Point(0, 0);\n","import type { Constructor, TBBox } from './typedefs';\nimport { removeFromArray } from './util/internals/removeFromArray';\nimport { Point } from './Point';\nimport type { ActiveSelection } from './shapes/ActiveSelection';\nimport type { Group } from './shapes/Group';\nimport type { InteractiveFabricObject } from './shapes/Object/InteractiveObject';\nimport type { FabricObject } from './shapes/Object/FabricObject';\n\nexport const isCollection = (\n fabricObject?: FabricObject,\n): fabricObject is Group | ActiveSelection => {\n return !!fabricObject && Array.isArray((fabricObject as Group)._objects);\n};\n\nexport function createCollectionMixin(Base: TBase) {\n class Collection extends Base {\n /**\n * @type {FabricObject[]}\n * @TODO needs to end up in the constructor too\n */\n _objects: FabricObject[] = [];\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectAdded(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onObjectRemoved(object: FabricObject) {\n // subclasses should override this method\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _onStackOrderChanged(object: FabricObject) {\n // subclasses should override this method\n }\n\n /**\n * Adds objects to collection\n * Objects should be instances of (or inherit from) FabricObject\n * @param {...FabricObject[]} objects to add\n * @returns {number} new array length\n */\n add(...objects: FabricObject[]): number {\n const size = this._objects.push(...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {number} index Index to insert object at\n * @param {...FabricObject[]} objects Object(s) to insert\n * @returns {number} new array length\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n this._objects.splice(index, 0, ...objects);\n objects.forEach((object) => this._onObjectAdded(object));\n return this._objects.length;\n }\n\n /**\n * Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)\n * @private\n * @param {...FabricObject[]} objects objects to remove\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const array = this._objects,\n removed: FabricObject[] = [];\n objects.forEach((object) => {\n const index = array.indexOf(object);\n // only call onObjectRemoved if an object was actually removed\n if (index !== -1) {\n array.splice(index, 1);\n removed.push(object);\n this._onObjectRemoved(object);\n }\n });\n return removed;\n }\n\n /**\n * Executes given function for each object in this group\n * A simple shortcut for getObjects().forEach, before es6 was more complicated,\n * now is just a shortcut.\n * @param {Function} callback\n * Callback invoked with current object as first argument,\n * index - as second and an array of all objects - as third.\n */\n forEachObject(\n callback: (\n object: FabricObject,\n index: number,\n array: FabricObject[],\n ) => any,\n ) {\n this.getObjects().forEach((object, index, objects) =>\n callback(object, index, objects),\n );\n }\n\n /**\n * Returns an array of children objects of this instance\n * @param {...String} [types] When specified, only objects of these types are returned\n * @return {Array}\n */\n getObjects(...types: string[]) {\n if (types.length === 0) {\n return [...this._objects];\n }\n return this._objects.filter((o) => o.isType(...types));\n }\n\n /**\n * Returns object at specified index\n * @param {Number} index\n * @return {Object} object at index\n */\n item(index: number) {\n return this._objects[index];\n }\n\n /**\n * Returns true if collection contains no objects\n * @return {Boolean} true if collection is empty\n */\n isEmpty() {\n return this._objects.length === 0;\n }\n\n /**\n * Returns a size of a collection (i.e: length of an array containing its objects)\n * @return {Number} Collection size\n */\n size() {\n return this._objects.length;\n }\n\n /**\n * Returns true if collection contains an object.\\\n * **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**\n * instead of `a.contains(b)` use `b.isDescendantOf(a)`\n * @param {Object} object Object to check against\n * @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`\n * @return {Boolean} `true` if collection contains an object\n */\n contains(object: FabricObject, deep?: boolean): boolean {\n if (this._objects.includes(object)) {\n return true;\n } else if (deep) {\n return this._objects.some(\n (obj) =>\n obj instanceof Collection &&\n (obj as unknown as Collection).contains(object, true),\n );\n }\n return false;\n }\n\n /**\n * Returns number representation of a collection complexity\n * @return {Number} complexity\n */\n complexity() {\n return this._objects.reduce((memo, current) => {\n memo += current.complexity ? current.complexity() : 0;\n return memo;\n }, 0);\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the bottom of the stack of drawn objects\n * @param {fabric.Object} object Object to send to back\n * @returns {boolean} true if change occurred\n */\n sendObjectToBack(object: FabricObject) {\n if (!object || object === this._objects[0]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.unshift(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or the objects of a multiple selection\n * to the top of the stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @returns {boolean} true if change occurred\n */\n bringObjectToFront(object: FabricObject) {\n if (!object || object === this._objects[this._objects.length - 1]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.push(object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n /**\n * Moves an object or a selection down in stack of drawn objects\n * An optional parameter, `intersecting` allows to move the object in behind\n * the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object behind next lower intersecting object\n * @returns {boolean} true if change occurred\n */\n sendObjectBackwards(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== 0) {\n // if object is not on the bottom of stack\n const newIdx = this.findNewLowerIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object or a selection up in stack of drawn objects\n * An optional parameter, intersecting allows to move the object in front\n * of the first intersecting object. Where intersection is calculated with\n * bounding box. If no intersection is found, there will not be change in the\n * stack.\n * @param {fabric.Object} object Object to send\n * @param {boolean} [intersecting] If `true`, send object in front of next upper intersecting object\n * @returns {boolean} true if change occurred\n */\n bringObjectForward(object: FabricObject, intersecting?: boolean) {\n if (!object) {\n return false;\n }\n const idx = this._objects.indexOf(object);\n if (idx !== this._objects.length - 1) {\n // if object is not on top of stack (last item in an array)\n const newIdx = this.findNewUpperIndex(object, idx, intersecting);\n removeFromArray(this._objects, object);\n this._objects.splice(newIdx, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n return false;\n }\n\n /**\n * Moves an object to specified level in stack of drawn objects\n * @param {fabric.Object} object Object to send\n * @param {number} index Position to move to\n * @returns {boolean} true if change occurred\n */\n moveObjectTo(object: FabricObject, index: number) {\n if (object === this._objects[index]) {\n return false;\n }\n removeFromArray(this._objects, object);\n this._objects.splice(index, 0, object);\n this._onStackOrderChanged(object);\n return true;\n }\n\n findNewLowerIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse down the stack looking for the nearest intersecting object\n for (let i = idx - 1; i >= 0; --i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx - 1;\n }\n\n return newIdx;\n }\n\n findNewUpperIndex(\n object: FabricObject,\n idx: number,\n intersecting?: boolean,\n ) {\n let newIdx;\n\n if (intersecting) {\n newIdx = idx;\n // traverse up the stack looking for the nearest intersecting object\n for (let i = idx + 1; i < this._objects.length; ++i) {\n if (object.isOverlapping(this._objects[i])) {\n newIdx = i;\n break;\n }\n }\n } else {\n newIdx = idx + 1;\n }\n\n return newIdx;\n }\n\n /**\n * Given a bounding box, return all the objects of the collection that are contained in the bounding box.\n * If `includeIntersecting` is true, return also the objects that intersect the bounding box as well.\n * This is meant to work with selection. Is not a generic method.\n * @param {TBBox} bbox a bounding box in scene coordinates\n * @param {{ includeIntersecting?: boolean }} options an object with includeIntersecting\n * @returns array of objects contained in the bounding box, ordered from top to bottom stacking wise\n */\n collectObjects(\n { left, top, width, height }: TBBox,\n { includeIntersecting = true }: { includeIntersecting?: boolean } = {},\n ) {\n const objects: InteractiveFabricObject[] = [],\n tl = new Point(left, top),\n br = tl.add(new Point(width, height));\n\n // we iterate reverse order to collect top first in case of click.\n for (let i = this._objects.length - 1; i >= 0; i--) {\n const object = this._objects[i] as unknown as InteractiveFabricObject;\n if (\n object.selectable &&\n object.visible &&\n ((includeIntersecting && object.intersectsWithRect(tl, br)) ||\n object.isContainedWithinRect(tl, br) ||\n (includeIntersecting && object.containsPoint(tl)) ||\n (includeIntersecting && object.containsPoint(br)))\n ) {\n objects.push(object);\n }\n }\n\n return objects;\n }\n }\n\n // https://github.com/microsoft/TypeScript/issues/32080\n return Collection as typeof Collection & TBase;\n}\n","import { Observable } from './Observable';\n\nexport class CommonMethods extends Observable {\n /**\n * Sets object's properties from options, for initialization only\n * @protected\n * @param {Object} [options] Options object\n */\n protected _setOptions(options: any = {}) {\n for (const prop in options) {\n this.set(prop, options[prop]);\n }\n }\n\n /**\n * @private\n */\n _setObject(obj: Record) {\n for (const prop in obj) {\n this._set(prop, obj[prop]);\n }\n }\n\n /**\n * Sets property to a given value. When changing position/dimension -related properties (left, top, scale, angle, etc.) `set` does not update position of object's borders/controls. If you need to update those, call `setCoords()`.\n * @param {String|Object} key Property name or object (if object, iterate over the object properties)\n * @param {Object|Function} value Property value (if function, the value is passed into it and its return value is used as a new one)\n */\n set(key: string | Record, value?: any) {\n if (typeof key === 'object') {\n this._setObject(key);\n } else {\n this._set(key, value);\n }\n return this;\n }\n\n _set(key: string, value: any) {\n this[key as keyof this] = value;\n }\n\n /**\n * Toggles specified property from `true` to `false` or from `false` to `true`\n * @param {String} property Property to toggle\n */\n toggle(property: string) {\n const value = this.get(property);\n if (typeof value === 'boolean') {\n this.set(property, !value);\n }\n return this;\n }\n\n /**\n * Basic getter\n * @param {String} property Property name\n * @return {*} value of a property\n */\n get(property: string): any {\n return this[property as keyof this];\n }\n}\n","import { getFabricWindow } from '../../env';\n\nexport function requestAnimFrame(callback: FrameRequestCallback): number {\n return getFabricWindow().requestAnimationFrame(callback);\n}\n\nexport function cancelAnimFrame(handle: number): void {\n return getFabricWindow().cancelAnimationFrame(handle);\n}\n","let id = 0;\n\nexport const uid = () => id++;\n","import { getFabricDocument } from '../../env';\nimport type { ImageFormat, TSize } from '../../typedefs';\nimport { FabricError } from '../internals/console';\n/**\n * Creates canvas element\n * @return {CanvasElement} initialized canvas element\n */\nexport const createCanvasElement = (): HTMLCanvasElement => {\n const element = getFabricDocument().createElement('canvas');\n if (!element || typeof element.getContext === 'undefined') {\n throw new FabricError('Failed to create `canvas` element');\n }\n return element;\n};\n\n/**\n * Creates image element (works on client and node)\n * @return {HTMLImageElement} HTML image element\n */\nexport const createImage = (): HTMLImageElement =>\n getFabricDocument().createElement('img');\n\n/**\n * Creates a canvas element that is a copy of another and is also painted\n * @param {CanvasElement} canvas to copy size and content of\n * @return {CanvasElement} initialized canvas element\n */\nexport const copyCanvasElement = (\n canvas: HTMLCanvasElement,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElementFor(canvas);\n newCanvas.getContext('2d')?.drawImage(canvas, 0, 0);\n return newCanvas;\n};\n\nexport const createCanvasElementFor = (\n canvas: HTMLCanvasElement | ImageData | HTMLImageElement | TSize,\n): HTMLCanvasElement => {\n const newCanvas = createCanvasElement();\n newCanvas.width = canvas.width;\n newCanvas.height = canvas.height;\n return newCanvas;\n};\n\n/**\n * since 2.6.0 moved from canvas instance to utility.\n * possibly useless\n * @param {CanvasElement} canvasEl to copy size and content of\n * @param {String} format 'jpeg' or 'png', in some browsers 'webp' is ok too\n * @param {Number} quality <= 1 and > 0\n * @return {String} data url\n */\nexport const toDataURL = (\n canvasEl: HTMLCanvasElement,\n format: ImageFormat,\n quality: number,\n) => canvasEl.toDataURL(`image/${format}`, quality);\n\nexport const isHTMLCanvas = (\n canvas?: HTMLCanvasElement | string,\n): canvas is HTMLCanvasElement => {\n return !!canvas && (canvas as HTMLCanvasElement).getContext !== undefined;\n};\n","import type { TRadian, TDegree } from '../../typedefs';\nimport { PiBy180 } from '../../constants';\n\n/**\n * Transforms degrees to radians.\n * @param {TDegree} degrees value in degrees\n * @return {TRadian} value in radians\n */\nexport const degreesToRadians = (degrees: TDegree): TRadian =>\n (degrees * PiBy180) as TRadian;\n\n/**\n * Transforms radians to degrees.\n * @param {TRadian} radians value in radians\n * @return {TDegree} value in degrees\n */\nexport const radiansToDegrees = (radians: TRadian): TDegree =>\n (radians / PiBy180) as TDegree;\n","import { iMatrix } from '../../constants';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TDegree, TRadian, TMat2D } from '../../typedefs';\nimport { cos } from './cos';\nimport { degreesToRadians, radiansToDegrees } from './radiansDegreesConversion';\nimport { sin } from './sin';\n\nexport type TRotateMatrixArgs = {\n angle?: TDegree;\n};\n\nexport type TTranslateMatrixArgs = {\n translateX?: number;\n translateY?: number;\n};\n\nexport type TScaleMatrixArgs = {\n scaleX?: number;\n scaleY?: number;\n flipX?: boolean;\n flipY?: boolean;\n skewX?: TDegree;\n skewY?: TDegree;\n};\n\nexport type TComposeMatrixArgs = TTranslateMatrixArgs &\n TRotateMatrixArgs &\n TScaleMatrixArgs;\n\nexport type TQrDecomposeOut = Required<\n Omit\n>;\n\nexport const isIdentityMatrix = (mat: TMat2D) =>\n mat.every((value, index) => value === iMatrix[index]);\n\n/**\n * Apply transform t to point p\n * @deprecated use {@link Point#transform}\n * @param {Point | XY} p The point to transform\n * @param {Array} t The transform\n * @param {Boolean} [ignoreOffset] Indicates that the offset should not be applied\n * @return {Point} The transformed point\n */\nexport const transformPoint = (\n p: XY,\n t: TMat2D,\n ignoreOffset?: boolean,\n): Point => new Point(p).transform(t, ignoreOffset);\n\n/**\n * Invert transformation t\n * @param {Array} t The transform\n * @return {Array} The inverted transform\n */\nexport const invertTransform = (t: TMat2D): TMat2D => {\n const a = 1 / (t[0] * t[3] - t[1] * t[2]),\n r = [a * t[3], -a * t[1], -a * t[2], a * t[0], 0, 0] as TMat2D,\n { x, y } = new Point(t[4], t[5]).transform(r, true);\n r[4] = -x;\n r[5] = -y;\n return r;\n};\n\n/**\n * Multiply matrix A by matrix B to nest transformations\n * @param {TMat2D} a First transformMatrix\n * @param {TMat2D} b Second transformMatrix\n * @param {Boolean} is2x2 flag to multiply matrices as 2x2 matrices\n * @return {TMat2D} The product of the two transform matrices\n */\nexport const multiplyTransformMatrices = (\n a: TMat2D,\n b: TMat2D,\n is2x2?: boolean,\n): TMat2D =>\n [\n a[0] * b[0] + a[2] * b[1],\n a[1] * b[0] + a[3] * b[1],\n a[0] * b[2] + a[2] * b[3],\n a[1] * b[2] + a[3] * b[3],\n is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4],\n is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5],\n ] as TMat2D;\n\n/**\n * Multiplies {@link matrices} such that a matrix defines the plane for the rest of the matrices **after** it\n *\n * `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`\n *\n * @param matrices an array of matrices\n * @param [is2x2] flag to multiply matrices as 2x2 matrices\n * @returns the multiplication product\n */\nexport const multiplyTransformMatrixArray = (\n matrices: (TMat2D | undefined | null | false)[],\n is2x2?: boolean,\n) =>\n matrices.reduceRight(\n (product: TMat2D, curr) =>\n curr && product\n ? multiplyTransformMatrices(curr, product, is2x2)\n : curr || product,\n undefined as unknown as TMat2D,\n ) || iMatrix.concat();\n\nexport const calcPlaneRotation = ([a, b]: TMat2D) =>\n Math.atan2(b, a) as TRadian;\n\n/**\n * Decomposes standard 2x3 matrix into transform components\n * @param {TMat2D} a transformMatrix\n * @return {Object} Components of transform\n */\nexport const qrDecompose = (a: TMat2D): TQrDecomposeOut => {\n const angle = calcPlaneRotation(a),\n denom = Math.pow(a[0], 2) + Math.pow(a[1], 2),\n scaleX = Math.sqrt(denom),\n scaleY = (a[0] * a[3] - a[2] * a[1]) / scaleX,\n skewX = Math.atan2(a[0] * a[2] + a[1] * a[3], denom);\n return {\n angle: radiansToDegrees(angle),\n scaleX,\n scaleY,\n skewX: radiansToDegrees(skewX),\n skewY: 0 as TDegree,\n translateX: a[4] || 0,\n translateY: a[5] || 0,\n };\n};\n\n/**\n * Generate a translation matrix\n *\n * A translation matrix in the form of\n * [ 1 0 x ]\n * [ 0 1 y ]\n * [ 0 0 1 ]\n *\n * See @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#translate for more details\n *\n * @param {number} x translation on X axis\n * @param {number} [y] translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createTranslateMatrix = (x: number, y = 0): TMat2D => [\n 1,\n 0,\n 0,\n 1,\n x,\n y,\n];\n\n/**\n * Generate a rotation matrix around around a point (x,y), defaulting to (0,0)\n *\n * A matrix in the form of\n * [cos(a) -sin(a) -x*cos(a)+y*sin(a)+x]\n * [sin(a) cos(a) -x*sin(a)-y*cos(a)+y]\n * [0 0 1 ]\n *\n *\n * @param {TDegree} angle rotation in degrees\n * @param {XY} [pivotPoint] pivot point to rotate around\n * @returns {TMat2D} matrix\n */\nexport function createRotateMatrix(\n { angle = 0 }: TRotateMatrixArgs = {},\n { x = 0, y = 0 }: Partial = {},\n): TMat2D {\n const angleRadiant = degreesToRadians(angle),\n cosValue = cos(angleRadiant),\n sinValue = sin(angleRadiant);\n return [\n cosValue,\n sinValue,\n -sinValue,\n cosValue,\n x ? x - (cosValue * x - sinValue * y) : 0,\n y ? y - (sinValue * x + cosValue * y) : 0,\n ];\n}\n\n/**\n * Generate a scale matrix around the point (0,0)\n *\n * A matrix in the form of\n * [x 0 0]\n * [0 y 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#scale\n *\n * @param {number} x scale on X axis\n * @param {number} [y] scale on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createScaleMatrix = (x: number, y: number = x): TMat2D => [\n x,\n 0,\n 0,\n y,\n 0,\n 0,\n];\n\nexport const angleToSkew = (angle: TDegree) =>\n Math.tan(degreesToRadians(angle));\n\nexport const skewToAngle = (value: TRadian) =>\n radiansToDegrees(Math.atan(value));\n\n/**\n * Generate a skew matrix for the X axis\n *\n * A matrix in the form of\n * [1 x 0]\n * [0 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewx\n *\n * @param {TDegree} skewValue translation on X axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewXMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n 0,\n angleToSkew(skewValue),\n 1,\n 0,\n 0,\n];\n\n/**\n * Generate a skew matrix for the Y axis\n *\n * A matrix in the form of\n * [1 0 0]\n * [y 1 0]\n * [0 0 1]\n *\n * @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/transform#skewy\n *\n * @param {TDegree} skewValue translation on Y axis\n * @returns {TMat2D} matrix\n */\nexport const createSkewYMatrix = (skewValue: TDegree): TMat2D => [\n 1,\n angleToSkew(skewValue),\n 0,\n 1,\n 0,\n 0,\n];\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet.\n * is called DimensionsTransformMatrix because those properties are the one that influence\n * the size of the resulting box of the object.\n * @param {Object} options\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @return {Number[]} transform matrix\n */\nexport const calcDimensionsMatrix = ({\n scaleX = 1,\n scaleY = 1,\n flipX = false,\n flipY = false,\n skewX = 0 as TDegree,\n skewY = 0 as TDegree,\n}: TScaleMatrixArgs) => {\n let matrix = createScaleMatrix(\n flipX ? -scaleX : scaleX,\n flipY ? -scaleY : scaleY,\n );\n if (skewX) {\n matrix = multiplyTransformMatrices(matrix, createSkewXMatrix(skewX), true);\n }\n if (skewY) {\n matrix = multiplyTransformMatrices(matrix, createSkewYMatrix(skewY), true);\n }\n return matrix;\n};\n\n/**\n * Returns a transform matrix starting from an object of the same kind of\n * the one returned from qrDecompose, useful also if you want to calculate some\n * transformations from an object that is not enlived yet\n * Before changing this function look at: src/benchmarks/calcTransformMatrix.mjs\n * @param {Object} options\n * @param {Number} [options.angle]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Boolean} [options.flipX]\n * @param {Boolean} [options.flipY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @param {Number} [options.translateX]\n * @param {Number} [options.translateY]\n * @return {Number[]} transform matrix\n */\nexport const composeMatrix = (options: TComposeMatrixArgs): TMat2D => {\n const { translateX = 0, translateY = 0, angle = 0 as TDegree } = options;\n let matrix = createTranslateMatrix(translateX, translateY);\n if (angle) {\n matrix = multiplyTransformMatrices(matrix, createRotateMatrix({ angle }));\n }\n const scaleMatrix = calcDimensionsMatrix(options);\n if (!isIdentityMatrix(scaleMatrix)) {\n matrix = multiplyTransformMatrices(matrix, scaleMatrix);\n }\n return matrix;\n};\n","import { noop } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport type {\n Abortable,\n Constructor,\n TCrossOrigin,\n TFiller,\n} from '../../typedefs';\nimport { createImage } from './dom';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { BaseFilter } from '../../filters/BaseFilter';\nimport type { FabricObject as BaseFabricObject } from '../../shapes/Object/Object';\nimport { FabricError, SignalAbortedError } from '../internals/console';\nimport type { Shadow } from '../../Shadow';\n\nexport type LoadImageOptions = Abortable & {\n /**\n * cors value for the image loading, default to anonymous\n */\n crossOrigin?: TCrossOrigin;\n};\n\n/**\n * Loads image element from given url and resolve it, or catch.\n * @param {String} url URL representing an image\n * @param {LoadImageOptions} [options] image loading options\n * @returns {Promise} the loaded image.\n */\nexport const loadImage = (\n url: string,\n { signal, crossOrigin = null }: LoadImageOptions = {},\n) =>\n new Promise(function (resolve, reject) {\n if (signal && signal.aborted) {\n return reject(new SignalAbortedError('loadImage'));\n }\n const img = createImage();\n let abort: EventListenerOrEventListenerObject;\n if (signal) {\n abort = function (err: Event) {\n img.src = '';\n reject(err);\n };\n signal.addEventListener('abort', abort, { once: true });\n }\n const done = function () {\n img.onload = img.onerror = null;\n abort && signal?.removeEventListener('abort', abort);\n resolve(img);\n };\n if (!url) {\n done();\n return;\n }\n img.onload = done;\n img.onerror = function () {\n abort && signal?.removeEventListener('abort', abort);\n reject(new FabricError(`Error loading ${img.src}`));\n };\n crossOrigin && (img.crossOrigin = crossOrigin);\n img.src = url;\n });\n\nexport type EnlivenObjectOptions = Abortable & {\n /**\n * Method for further parsing of object elements,\n * called after each fabric object created.\n */\n reviver?: <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n >(\n serializedObj: Record,\n instance: T,\n ) => void;\n};\n\n/**\n * @TODO type this correctly.\n * Creates corresponding fabric instances from their object representations\n * @param {Object[]} objects Objects to enliven\n * @param {EnlivenObjectOptions} [options]\n * @param {(serializedObj: object, instance: FabricObject) => any} [options.reviver] Method for further parsing of object elements,\n * called after each fabric object created.\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\nexport const enlivenObjects = <\n T extends\n | BaseFabricObject\n | FabricObject\n | BaseFilter\n | Shadow\n | TFiller,\n>(\n objects: any[],\n { signal, reviver = noop }: EnlivenObjectOptions = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: T[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n Promise.all(\n objects.map((obj) =>\n classRegistry\n .getClass<\n Constructor & {\n fromObject(options: any, context: Abortable): Promise;\n }\n >(obj.type)\n .fromObject(obj, { signal })\n .then((fabricInstance) => {\n reviver(obj, fabricInstance);\n instances.push(fabricInstance);\n return fabricInstance;\n }),\n ),\n )\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance) => {\n (instance as FabricObject).dispose &&\n (instance as FabricObject).dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n\n/**\n * Creates corresponding fabric instances residing in an object, e.g. `clipPath`\n * @param {Object} object with properties to enlive ( fill, stroke, clipPath, path )\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise>} the input object with enlived values\n */\nexport const enlivenObjectEnlivables = <\n R = Record,\n>(\n serializedObject: any,\n { signal }: Abortable = {},\n) =>\n new Promise((resolve, reject) => {\n const instances: (FabricObject | TFiller | Shadow)[] = [];\n signal && signal.addEventListener('abort', reject, { once: true });\n // enlive every possible property\n const promises = Object.values(serializedObject).map((value: any) => {\n if (!value) {\n return value;\n }\n /**\n * clipPath or shadow or gradient or text on a path or a pattern,\n * or the backgroundImage or overlayImage of canvas\n * If we have a type and there is a classe registered for it, we enlive it.\n * If there is no class registered for it we return the value as is\n * */\n if (value.type && classRegistry.has(value.type)) {\n return enlivenObjects([value], {\n signal,\n }).then(([enlived]) => {\n instances.push(enlived);\n return enlived;\n });\n }\n return value;\n });\n const keys = Object.keys(serializedObject);\n Promise.all(promises)\n .then((enlived) => {\n return enlived.reduce((acc, instance, index) => {\n acc[keys[index]] = instance;\n return acc;\n }, {});\n })\n .then(resolve)\n .catch((error) => {\n // cleanup\n instances.forEach((instance: any) => {\n instance.dispose && instance.dispose();\n });\n reject(error);\n })\n .finally(() => {\n signal && signal.removeEventListener('abort', reject);\n });\n });\n","/**\n * Populates an object with properties of another object\n * @param {Object} source Source object\n * @param {string[]} properties Properties names to include\n * @returns object populated with the picked keys\n */\nexport const pick = >(\n source: T,\n keys: (keyof T)[] = [],\n) => {\n return keys.reduce((o, key) => {\n if (key in source) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n\nexport const pickBy = >(\n source: T,\n predicate: (value: T[K], key: K, collection: T) => boolean,\n) => {\n return (Object.keys(source) as (keyof T)[]).reduce((o, key) => {\n if (predicate(source[key], key, source)) {\n o[key] = source[key];\n }\n return o;\n }, {} as Partial);\n};\n","/**\n * Map of the 148 color names with HEX code\n * @see: https://www.w3.org/TR/css3-color/#svg-color\n */\nexport const ColorNameMap = {\n aliceblue: '#F0F8FF',\n antiquewhite: '#FAEBD7',\n aqua: '#0FF',\n aquamarine: '#7FFFD4',\n azure: '#F0FFFF',\n beige: '#F5F5DC',\n bisque: '#FFE4C4',\n black: '#000',\n blanchedalmond: '#FFEBCD',\n blue: '#00F',\n blueviolet: '#8A2BE2',\n brown: '#A52A2A',\n burlywood: '#DEB887',\n cadetblue: '#5F9EA0',\n chartreuse: '#7FFF00',\n chocolate: '#D2691E',\n coral: '#FF7F50',\n cornflowerblue: '#6495ED',\n cornsilk: '#FFF8DC',\n crimson: '#DC143C',\n cyan: '#0FF',\n darkblue: '#00008B',\n darkcyan: '#008B8B',\n darkgoldenrod: '#B8860B',\n darkgray: '#A9A9A9',\n darkgrey: '#A9A9A9',\n darkgreen: '#006400',\n darkkhaki: '#BDB76B',\n darkmagenta: '#8B008B',\n darkolivegreen: '#556B2F',\n darkorange: '#FF8C00',\n darkorchid: '#9932CC',\n darkred: '#8B0000',\n darksalmon: '#E9967A',\n darkseagreen: '#8FBC8F',\n darkslateblue: '#483D8B',\n darkslategray: '#2F4F4F',\n darkslategrey: '#2F4F4F',\n darkturquoise: '#00CED1',\n darkviolet: '#9400D3',\n deeppink: '#FF1493',\n deepskyblue: '#00BFFF',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1E90FF',\n firebrick: '#B22222',\n floralwhite: '#FFFAF0',\n forestgreen: '#228B22',\n fuchsia: '#F0F',\n gainsboro: '#DCDCDC',\n ghostwhite: '#F8F8FF',\n gold: '#FFD700',\n goldenrod: '#DAA520',\n gray: '#808080',\n grey: '#808080',\n green: '#008000',\n greenyellow: '#ADFF2F',\n honeydew: '#F0FFF0',\n hotpink: '#FF69B4',\n indianred: '#CD5C5C',\n indigo: '#4B0082',\n ivory: '#FFFFF0',\n khaki: '#F0E68C',\n lavender: '#E6E6FA',\n lavenderblush: '#FFF0F5',\n lawngreen: '#7CFC00',\n lemonchiffon: '#FFFACD',\n lightblue: '#ADD8E6',\n lightcoral: '#F08080',\n lightcyan: '#E0FFFF',\n lightgoldenrodyellow: '#FAFAD2',\n lightgray: '#D3D3D3',\n lightgrey: '#D3D3D3',\n lightgreen: '#90EE90',\n lightpink: '#FFB6C1',\n lightsalmon: '#FFA07A',\n lightseagreen: '#20B2AA',\n lightskyblue: '#87CEFA',\n lightslategray: '#789',\n lightslategrey: '#789',\n lightsteelblue: '#B0C4DE',\n lightyellow: '#FFFFE0',\n lime: '#0F0',\n limegreen: '#32CD32',\n linen: '#FAF0E6',\n magenta: '#F0F',\n maroon: '#800000',\n mediumaquamarine: '#66CDAA',\n mediumblue: '#0000CD',\n mediumorchid: '#BA55D3',\n mediumpurple: '#9370DB',\n mediumseagreen: '#3CB371',\n mediumslateblue: '#7B68EE',\n mediumspringgreen: '#00FA9A',\n mediumturquoise: '#48D1CC',\n mediumvioletred: '#C71585',\n midnightblue: '#191970',\n mintcream: '#F5FFFA',\n mistyrose: '#FFE4E1',\n moccasin: '#FFE4B5',\n navajowhite: '#FFDEAD',\n navy: '#000080',\n oldlace: '#FDF5E6',\n olive: '#808000',\n olivedrab: '#6B8E23',\n orange: '#FFA500',\n orangered: '#FF4500',\n orchid: '#DA70D6',\n palegoldenrod: '#EEE8AA',\n palegreen: '#98FB98',\n paleturquoise: '#AFEEEE',\n palevioletred: '#DB7093',\n papayawhip: '#FFEFD5',\n peachpuff: '#FFDAB9',\n peru: '#CD853F',\n pink: '#FFC0CB',\n plum: '#DDA0DD',\n powderblue: '#B0E0E6',\n purple: '#800080',\n rebeccapurple: '#639',\n red: '#F00',\n rosybrown: '#BC8F8F',\n royalblue: '#4169E1',\n saddlebrown: '#8B4513',\n salmon: '#FA8072',\n sandybrown: '#F4A460',\n seagreen: '#2E8B57',\n seashell: '#FFF5EE',\n sienna: '#A0522D',\n silver: '#C0C0C0',\n skyblue: '#87CEEB',\n slateblue: '#6A5ACD',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#FFFAFA',\n springgreen: '#00FF7F',\n steelblue: '#4682B4',\n tan: '#D2B48C',\n teal: '#008080',\n thistle: '#D8BFD8',\n tomato: '#FF6347',\n turquoise: '#40E0D0',\n violet: '#EE82EE',\n wheat: '#F5DEB3',\n white: '#FFF',\n whitesmoke: '#F5F5F5',\n yellow: '#FF0',\n yellowgreen: '#9ACD32',\n};\n","/**\n * Regex matching color in RGB or RGBA formats (ex: `rgb(0, 0, 0)`, `rgba(255, 100, 10, 0.5)`, `rgba( 255 , 100 , 10 , 0.5 )`, `rgb(1,1,1)`, `rgba(100%, 60%, 10%, 0.5)`)\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb\n * Formal syntax at the time of writing:\n * =\n * rgb( [ | none ]{3} [ / [ | none ] ]? ) |\n * rgb( [ | none ]{3} [ / [ | none ] ]? )\n * = | \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an rgba or rgb CSS color value\n *\n * /^ # Beginning of the string\n * rgba? # \"rgb\" or \"rgba\"\n * \\(\\s* # Opening parenthesis and optional whitespace\n * (\\d{0,3} # 0 to three digits R channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the first color component\n * %? # Optional percent sign after the first color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits G channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the second color component\n * %? # Optional percent sign after the second color component\n * \\s* # Optional whitespace\n * [\\s|,] # Separator between color components can be a space or comma\n * \\s* # Optional whitespace\n * (\\d{0,3} # 0 to three digits B channel\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for the third color component\n * %? # Optional percent sign after the third color component\n * \\s* # Optional whitespace\n * (?: # Beginning of non-capturing group for alpha value\n * \\s* # Optional whitespace\n * [,/] # Comma or slash separator for alpha value\n * \\s* # Optional whitespace\n * (\\d{0,3} # Zero to three digits\n * (?:\\.\\d+)? # Optional decimal with one or more digits\n * ) # End of capturing group for alpha value\n * %? # Optional percent sign after alpha value\n * \\s* # Optional whitespace\n * )? # End of non-capturing group for alpha value (optional)\n * \\) # Closing parenthesis\n * $ # End of the string\n *\n * The alpha channel can be in the format 0.4 .7 or 1 or 73%\n *\n * WARNING this regex doesn't fail on off spec colors. it matches everything that could be a color.\n * So the spec does not allow for `rgba(30 , 45% 35, 49%)` but this will work anyways for us\n */\nexport const reRGBa = () =>\n /^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;\n\n/**\n * Regex matching color in HSL or HSLA formats (ex: hsl(0, 0, 0), rgba(255, 100, 10, 0.5), rgba( 255 , 100 , 10 , 0.5 ), rgb(1,1,1), rgba(100%, 60%, 10%, 0.5))\n * Also matching rgba(r g b / a) as per new specs\n * https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl\n * Formal syntax at the time of writing:\n * =\n * hsl( [ | none ] [ | none ] [ | none ] [ / [ | none ] ]? )\n *\n * =\n * |\n * \n *\n * =\n * |\n * \n *\n * For learners this is how you can read this regex\n * Regular expression for matching an hsla or hsl CSS color value\n *\n * /^hsla?\\( // Matches the beginning of the string and the opening parenthesis of \"hsl\" or \"hsla\"\n * \\s* // Matches any whitespace characters (space, tab, etc.) zero or more times\n * (\\d{0,3} // Hue: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Hue: Optional (non capture group) decimal with one or more digits.\n * (?:deg|turn|rad)? // Hue: Optionally include suffix deg or turn or rad\n * ) // Hue: End capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Saturation: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Saturation: Optional decimal with one or more digits in a non-capturing group\n * %?) // Saturation: match optional % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * [\\s|,] // Matches a space, tab or comma\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d{0,3} // Lightness: 0 to three digits - start capture in a group\n * (?:\\.\\d+)? // Lightness: Optional decimal with one or more digits in a non-capturing group\n * %?) // Lightness: match % character and end capture group\n * \\s* // Matches any whitespace characters zero or more times\n * (?: // Alpha: Begins a non-capturing group for the alpha value\n * \\s* // Matches any whitespace characters zero or more times\n * [,/] // Matches a comma or forward slash\n * \\s* // Matches any whitespace characters zero or more times\n * (\\d*(?:\\.\\d+)?%?) // Matches zero or more digits, optionally followed by a decimal point and one or more digits, followed by an optional percentage sign and captures it in a group\n * \\s* // Matches any whitespace characters zero or more times\n * )? // Makes the alpha value group optional\n * \\) // Matches the closing parenthesis\n * $/i // Matches the end of the string and sets the regular expression to case-insensitive mode\n *\n * WARNING this regex doesn't fail on off spec colors. It matches everything that could be a color.\n * So the spec does not allow `hsl(30 , 45% 35, 49%)` but this will work anyways for us.\n */\nexport const reHSLa = () =>\n /^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;\n\n/**\n * Regex matching color in HEX format (ex: #FF5544CC, #FF5555, 010155, aff)\n */\nexport const reHex = () => /^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i;\n","import type { TRGBAColorSource } from './typedefs';\n\n/**\n * @param {Number} p\n * @param {Number} q\n * @param {Number} t\n * @return {Number}\n */\nexport const hue2rgb = (p: number, q: number, t: number): number => {\n if (t < 0) {\n t += 1;\n }\n if (t > 1) {\n t -= 1;\n }\n if (t < 1 / 6) {\n return p + (q - p) * 6 * t;\n }\n if (t < 1 / 2) {\n return q;\n }\n if (t < 2 / 3) {\n return p + (q - p) * (2 / 3 - t) * 6;\n }\n return p;\n};\n\n/**\n * Adapted from {@link https://gist.github.com/mjackson/5311256 https://gist.github.com/mjackson}\n * @param {Number} r Red color value\n * @param {Number} g Green color value\n * @param {Number} b Blue color value\n * @param {Number} a Alpha color value pass through\n * @return {TRGBColorSource} Hsl color\n */\nexport const rgb2Hsl = (\n r: number,\n g: number,\n b: number,\n a: number,\n): TRGBAColorSource => {\n r /= 255;\n g /= 255;\n b /= 255;\n const maxValue = Math.max(r, g, b),\n minValue = Math.min(r, g, b);\n\n let h!: number, s: number;\n const l = (maxValue + minValue) / 2;\n\n if (maxValue === minValue) {\n h = s = 0; // achromatic\n } else {\n const d = maxValue - minValue;\n s = l > 0.5 ? d / (2 - maxValue - minValue) : d / (maxValue + minValue);\n switch (maxValue) {\n case r:\n h = (g - b) / d + (g < b ? 6 : 0);\n break;\n case g:\n h = (b - r) / d + 2;\n break;\n case b:\n h = (r - g) / d + 4;\n break;\n }\n h /= 6;\n }\n\n return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100), a];\n};\n\nexport const fromAlphaToFloat = (value = '1') =>\n parseFloat(value) / (value.endsWith('%') ? 100 : 1);\n\n/**\n * Convert a value in the inclusive range [0, 255] to hex\n */\nexport const hexify = (value: number) =>\n Math.min(Math.round(value), 255).toString(16).toUpperCase().padStart(2, '0');\n\n/**\n * Calculate the grey average value for rgb and pass through alpha\n */\nexport const greyAverage = ([\n r,\n g,\n b,\n a = 1,\n]: TRGBAColorSource): TRGBAColorSource => {\n const avg = Math.round(r * 0.3 + g * 0.59 + b * 0.11);\n return [avg, avg, avg, a];\n};\n","import { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { ColorNameMap } from './color_map';\nimport { reHSLa, reHex, reRGBa } from './constants';\nimport type { TRGBAColorSource, TColorArg } from './typedefs';\nimport {\n hue2rgb,\n hexify,\n rgb2Hsl,\n fromAlphaToFloat,\n greyAverage,\n} from './util';\n\n/**\n * @class Color common color operations\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2/#colors colors}\n */\nexport class Color {\n private declare _source: TRGBAColorSource;\n isUnrecognised = false;\n\n /**\n *\n * @param {string} [color] optional in hex or rgb(a) or hsl format or from known color list\n */\n constructor(color?: TColorArg) {\n if (!color) {\n // we default to black as canvas does\n this.setSource([0, 0, 0, 1]);\n } else if (color instanceof Color) {\n this.setSource([...color._source]);\n } else if (Array.isArray(color)) {\n const [r, g, b, a = 1] = color;\n this.setSource([r, g, b, a]);\n } else {\n this.setSource(this._tryParsingColor(color));\n }\n }\n\n /**\n * @private\n * @param {string} [color] Color value to parse\n * @returns {TRGBAColorSource}\n */\n protected _tryParsingColor(color: string) {\n color = color.toLowerCase();\n if (color in ColorNameMap) {\n color = ColorNameMap[color as keyof typeof ColorNameMap];\n }\n return color === 'transparent'\n ? ([255, 255, 255, 0] as TRGBAColorSource)\n : Color.sourceFromHex(color) ||\n Color.sourceFromRgb(color) ||\n Color.sourceFromHsl(color) ||\n // color is not recognized\n // we default to black as canvas does\n // eslint-disable-next-line no-constant-binary-expression\n ((this.isUnrecognised = true) && ([0, 0, 0, 1] as TRGBAColorSource));\n }\n\n /**\n * Returns source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @return {TRGBAColorSource}\n */\n getSource() {\n return this._source;\n }\n\n /**\n * Sets source of this color (where source is an array representation; ex: [200, 200, 100, 1])\n * @param {TRGBAColorSource} source\n */\n setSource(source: TRGBAColorSource) {\n this._source = source;\n }\n\n /**\n * Returns color representation in RGB format\n * @return {String} ex: rgb(0-255,0-255,0-255)\n */\n toRgb() {\n const [r, g, b] = this.getSource();\n return `rgb(${r},${g},${b})`;\n }\n\n /**\n * Returns color representation in RGBA format\n * @return {String} ex: rgba(0-255,0-255,0-255,0-1)\n */\n toRgba() {\n return `rgba(${this.getSource().join(',')})`;\n }\n\n /**\n * Returns color representation in HSL format\n * @return {String} ex: hsl(0-360,0%-100%,0%-100%)\n */\n toHsl() {\n const [h, s, l] = rgb2Hsl(...this.getSource());\n return `hsl(${h},${s}%,${l}%)`;\n }\n\n /**\n * Returns color representation in HSLA format\n * @return {String} ex: hsla(0-360,0%-100%,0%-100%,0-1)\n */\n toHsla() {\n const [h, s, l, a] = rgb2Hsl(...this.getSource());\n return `hsla(${h},${s}%,${l}%,${a})`;\n }\n\n /**\n * Returns color representation in HEX format\n * @return {String} ex: FF5555\n */\n toHex() {\n const fullHex = this.toHexa();\n return fullHex.slice(0, 6);\n }\n\n /**\n * Returns color representation in HEXA format\n * @return {String} ex: FF5555CC\n */\n toHexa() {\n const [r, g, b, a] = this.getSource();\n return `${hexify(r)}${hexify(g)}${hexify(b)}${hexify(Math.round(a * 255))}`;\n }\n\n /**\n * Gets value of alpha channel for this color\n * @return {Number} 0-1\n */\n getAlpha() {\n return this.getSource()[3];\n }\n\n /**\n * Sets value of alpha channel for this color\n * @param {Number} alpha Alpha value 0-1\n * @return {Color} thisArg\n */\n setAlpha(alpha: number) {\n this._source[3] = alpha;\n return this;\n }\n\n /**\n * Transforms color to its grayscale representation\n * @return {Color} thisArg\n */\n toGrayscale() {\n this.setSource(greyAverage(this.getSource()));\n return this;\n }\n\n /**\n * Transforms color to its black and white representation\n * @param {Number} threshold\n * @return {Color} thisArg\n */\n toBlackWhite(threshold: number) {\n const [average, , , a] = greyAverage(this.getSource()),\n bOrW = average < (threshold || 127) ? 0 : 255;\n this.setSource([bOrW, bOrW, bOrW, a]);\n return this;\n }\n\n /**\n * Overlays color with another color\n * @param {String|Color} otherColor\n * @return {Color} thisArg\n */\n overlayWith(otherColor: string | Color) {\n if (!(otherColor instanceof Color)) {\n otherColor = new Color(otherColor);\n }\n\n const source = this.getSource(),\n otherAlpha = 0.5,\n otherSource = otherColor.getSource(),\n [R, G, B] = source.map((value, index) =>\n Math.round(value * (1 - otherAlpha) + otherSource[index] * otherAlpha),\n );\n\n this.setSource([R, G, B, source[3]]);\n return this;\n }\n\n /**\n * Returns new color object, when given a color in RGB format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255)\n * @return {Color}\n */\n static fromRgb(color: string): Color {\n return Color.fromRgba(color);\n }\n\n /**\n * Returns new color object, when given a color in RGBA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromRgba(color: string): Color {\n return new Color(Color.sourceFromRgb(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in RGB or RGBA format\n * @memberOf Color\n * @param {String} color Color value ex: rgb(0-255,0-255,0-255), rgb(0%-100%,0%-100%,0%-100%)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromRgb(color: string): TRGBAColorSource | undefined {\n const match = color.match(reRGBa());\n if (match) {\n const [r, g, b] = match.slice(1, 4).map((value) => {\n const parsedValue = parseFloat(value);\n return value.endsWith('%')\n ? Math.round(parsedValue * 2.55)\n : parsedValue;\n });\n return [r, g, b, fromAlphaToFloat(match[4])];\n }\n }\n\n /**\n * Returns new color object, when given a color in HSL format\n * @param {String} color Color value ex: hsl(0-260,0%-100%,0%-100%)\n * @memberOf Color\n * @return {Color}\n */\n static fromHsl(color: string): Color {\n return Color.fromHsla(color);\n }\n\n /**\n * Returns new color object, when given a color in HSLA format\n * @static\n * @function\n * @memberOf Color\n * @param {String} color\n * @return {Color}\n */\n static fromHsla(color: string): Color {\n return new Color(Color.sourceFromHsl(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HSL or HSLA format.\n * Adapted from https://github.com/mjijackson\n * @memberOf Color\n * @param {String} color Color value ex: hsl(0-360,0%-100%,0%-100%) or hsla(0-360,0%-100%,0%-100%, 0-1)\n * @return {TRGBAColorSource | undefined} source\n * @see http://http://www.w3.org/TR/css3-color/#hsl-color\n */\n static sourceFromHsl(color: string): TRGBAColorSource | undefined {\n const match = color.match(reHSLa());\n if (!match) {\n return;\n }\n const match1degrees = Color.parseAngletoDegrees(match[1]);\n\n const h = (((match1degrees % 360) + 360) % 360) / 360,\n s = parseFloat(match[2]) / 100,\n l = parseFloat(match[3]) / 100;\n let r: number, g: number, b: number;\n\n if (s === 0) {\n r = g = b = l;\n } else {\n const q = l <= 0.5 ? l * (s + 1) : l + s - l * s,\n p = l * 2 - q;\n\n r = hue2rgb(p, q, h + 1 / 3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1 / 3);\n }\n\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n fromAlphaToFloat(match[4]),\n ];\n }\n\n /**\n * Returns new color object, when given a color in HEX format\n * @static\n * @memberOf Color\n * @param {String} color Color value ex: FF5555\n * @return {Color}\n */\n static fromHex(color: string): Color {\n return new Color(Color.sourceFromHex(color));\n }\n\n /**\n * Returns array representation (ex: [100, 100, 200, 1]) of a color that's in HEX format\n * @static\n * @memberOf Color\n * @param {String} color ex: FF5555 or FF5544CC (RGBa)\n * @return {TRGBAColorSource | undefined} source\n */\n static sourceFromHex(color: string): TRGBAColorSource | undefined {\n if (color.match(reHex())) {\n const value = color.slice(color.indexOf('#') + 1),\n isShortNotation = value.length <= 4;\n let expandedValue: string[];\n if (isShortNotation) {\n expandedValue = value.split('').map((hex) => hex + hex);\n } else {\n expandedValue = value.match(/.{2}/g)!;\n }\n const [r, g, b, a = 255] = expandedValue.map((hexCouple) =>\n parseInt(hexCouple, 16),\n );\n return [r, g, b, a / 255];\n }\n }\n\n /**\n * Converts a string that could be any angle notation (50deg, 0.5turn, 2rad)\n * into degrees without the 'deg' suffix\n * @static\n * @memberOf Color\n * @param {String} value ex: 0deg, 0.5turn, 2rad\n * @return {Number} number in degrees or NaN if inputs are invalid\n */\n static parseAngletoDegrees(value: string): number {\n const lowercase = value.toLowerCase();\n const numeric = parseFloat(lowercase);\n\n if (lowercase.includes('rad')) {\n return radiansToDegrees(numeric);\n }\n\n if (lowercase.includes('turn')) {\n return numeric * 360;\n }\n\n // Value is probably just a number already in degrees eg '50'\n return numeric;\n }\n}\n","/**\n * A wrapper around Number#toFixed, which contrary to native method returns number, not string.\n * @param {number|string} number number to operate on\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {number}\n */\nexport const toFixed = (number: number | string, fractionDigits: number) =>\n parseFloat(Number(number).toFixed(fractionDigits));\n","import { Color } from '../../color/Color';\nimport { config } from '../../config';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, NONE } from '../../constants';\nimport type {\n TBBox,\n TMat2D,\n SVGElementName,\n SupportedSVGUnit,\n} from '../../typedefs';\nimport { toFixed } from './toFixed';\n\n/**\n * Returns array of attributes for given svg that fabric parses\n * @param {SVGElementName} type Type of svg element (eg. 'circle')\n * @return {Array} string names of supported attributes\n */\nexport const getSvgAttributes = (type: SVGElementName) => {\n const commonAttributes = ['instantiated_by_use', 'style', 'id', 'class'];\n switch (type) {\n case 'linearGradient':\n return commonAttributes.concat([\n 'x1',\n 'y1',\n 'x2',\n 'y2',\n 'gradientUnits',\n 'gradientTransform',\n ]);\n case 'radialGradient':\n return commonAttributes.concat([\n 'gradientUnits',\n 'gradientTransform',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n 'fr',\n ]);\n case 'stop':\n return commonAttributes.concat(['offset', 'stop-color', 'stop-opacity']);\n }\n return commonAttributes;\n};\n\n/**\n * Converts from attribute value to pixel value if applicable.\n * Returns converted pixels or original value not converted.\n * @param {string} value number to operate on\n * @param {number} fontSize\n * @return {number}\n */\nexport const parseUnit = (value: string, fontSize = DEFAULT_SVG_FONT_SIZE) => {\n const unit = /\\D{0,2}$/.exec(value),\n number = parseFloat(value);\n const dpi = config.DPI;\n switch (unit?.[0] as SupportedSVGUnit) {\n case 'mm':\n return (number * dpi) / 25.4;\n\n case 'cm':\n return (number * dpi) / 2.54;\n\n case 'in':\n return number * dpi;\n\n case 'pt':\n return (number * dpi) / 72; // or * 4 / 3\n\n case 'pc':\n return ((number * dpi) / 72) * 12; // or * 16\n\n case 'em':\n return number * fontSize;\n\n default:\n return number;\n }\n};\n\nexport type MeetOrSlice = 'meet' | 'slice';\n\nexport type MinMidMax = 'Min' | 'Mid' | 'Max' | 'none';\n\nexport type TPreserveArParsed = {\n meetOrSlice: MeetOrSlice;\n alignX: MinMidMax;\n alignY: MinMidMax;\n};\n\n// align can be either none or undefined or a combination of mid/max\nconst parseAlign = (align: string): MinMidMax[] => {\n //divide align in alignX and alignY\n if (align && align !== NONE) {\n return [align.slice(1, 4) as MinMidMax, align.slice(5, 8) as MinMidMax];\n } else if (align === NONE) {\n return [align, align];\n }\n return ['Mid', 'Mid'];\n};\n\n/**\n * Parse preserveAspectRatio attribute from element\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio\n * @param {string} attribute to be parsed\n * @return {Object} an object containing align and meetOrSlice attribute\n */\nexport const parsePreserveAspectRatioAttribute = (\n attribute: string,\n): TPreserveArParsed => {\n const [firstPart, secondPart] = attribute.trim().split(' ') as [\n MinMidMax,\n MeetOrSlice | undefined,\n ];\n const [alignX, alignY] = parseAlign(firstPart);\n return {\n meetOrSlice: secondPart || 'meet',\n alignX,\n alignY,\n };\n};\n\n/**\n * given an array of 6 number returns something like `\"matrix(...numbers)\"`\n * @param {TMat2D} transform an array with 6 numbers\n * @return {String} transform matrix for svg\n */\nexport const matrixToSVG = (transform: TMat2D) =>\n 'matrix(' +\n transform\n .map((value) => toFixed(value, config.NUM_FRACTION_DIGITS))\n .join(' ') +\n ')';\n\n/**\n * Adobe Illustrator (at least CS5) is unable to render rgba()-based fill values\n * we work around it by \"moving\" alpha channel into opacity attribute and setting fill's alpha to 1\n * @param prop\n * @param value\n * @param {boolean} inlineStyle The default is inline style, the separator used is \":\", The other is \"=\"\n * @returns\n */\nexport const colorPropToSVG = (\n prop: string,\n value?: any,\n inlineStyle = true,\n) => {\n let colorValue;\n let opacityValue;\n if (!value) {\n colorValue = 'none';\n } else if (value.toLive) {\n colorValue = `url(#SVGID_${value.id})`;\n } else {\n const color = new Color(value),\n opacity = color.getAlpha();\n\n colorValue = color.toRgb();\n if (opacity !== 1) {\n opacityValue = opacity.toString();\n }\n }\n if (inlineStyle) {\n return `${prop}: ${colorValue}; ${\n opacityValue ? `${prop}-opacity: ${opacityValue}; ` : ''\n }`;\n } else {\n return `${prop}=\"${colorValue}\" ${\n opacityValue ? `${prop}-opacity=\"${opacityValue}\" ` : ''\n }`;\n }\n};\n\nexport const createSVGRect = (\n color: string,\n { left, top, width, height }: TBBox,\n precision = config.NUM_FRACTION_DIGITS,\n) => {\n const svgColor = colorPropToSVG(FILL, color, false);\n const [x, y, w, h] = [left, top, width, height].map((value) =>\n toFixed(value, precision),\n );\n return ``;\n};\n","import type { FabricObject } from '../shapes/Object/Object';\nimport type { TFiller } from '../typedefs';\nimport type { FabricText } from '../shapes/Text/Text';\nimport type { Pattern } from '../Pattern';\nimport type { Path } from '../shapes/Path';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\n\nexport const isFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && (filler as TFiller).toLive !== undefined;\n};\n\nexport const isSerializableFiller = (\n filler: TFiller | string | null,\n): filler is TFiller => {\n return !!filler && typeof (filler as TFiller).toObject === 'function';\n};\n\nexport const isPattern = (filler: TFiller): filler is Pattern => {\n return (\n !!filler && (filler as Pattern).offsetX !== undefined && 'source' in filler\n );\n};\n\nexport const isTextObject = (\n fabricObject?: FabricObject,\n): fabricObject is FabricText => {\n return (\n !!fabricObject &&\n typeof (fabricObject as FabricText)._renderText === 'function'\n );\n};\n\nexport const isPath = (fabricObject?: FabricObject): fabricObject is Path => {\n // we could use instanceof but that would mean pulling in Text code for a simple check\n // @todo discuss what to do and how to do\n return (\n !!fabricObject &&\n typeof (fabricObject as Path)._renderPathCommands === 'function'\n );\n};\n\nexport const isActiveSelection = (\n fabricObject?: FabricObject,\n): fabricObject is ActiveSelection =>\n !!fabricObject && 'multiSelectionStacking' in fabricObject;\n","/**\n * Returns element scroll offsets\n * @param {HTMLElement} element Element to operate on\n * @return {Object} Object with left/top values\n */\nexport function getScrollLeftTop(element: HTMLElement | null) {\n const doc = element && getDocumentFromElement(element);\n let left = 0,\n top = 0;\n if (!element || !doc) {\n return { left, top };\n }\n let elementLoop: HTMLElement | Document | ShadowRoot = element;\n const docElement = doc.documentElement,\n body = doc.body || {\n scrollLeft: 0,\n scrollTop: 0,\n };\n // While loop checks (and then sets element to) .parentNode OR .host\n // to account for ShadowDOM. We still want to traverse up out of ShadowDOM,\n // but the .parentNode of a root ShadowDOM node will always be null, instead\n // it should be accessed through .host. See http://stackoverflow.com/a/24765528/4383938\n while (\n elementLoop &&\n (elementLoop.parentNode || (elementLoop as unknown as ShadowRoot).host)\n ) {\n elementLoop = (elementLoop.parentNode ||\n (elementLoop as unknown as ShadowRoot).host) as\n | HTMLElement\n | Document\n | ShadowRoot;\n if (elementLoop === doc) {\n left = body.scrollLeft || docElement.scrollLeft || 0;\n top = body.scrollTop || docElement.scrollTop || 0;\n } else {\n left += (elementLoop as HTMLElement).scrollLeft || 0;\n top += (elementLoop as HTMLElement).scrollTop || 0;\n }\n\n if (\n elementLoop.nodeType === 1 &&\n (elementLoop as HTMLElement).style.position === 'fixed'\n ) {\n break;\n }\n }\n\n return { left, top };\n}\n\nexport const getDocumentFromElement = (el: HTMLElement) =>\n el.ownerDocument || null;\n\nexport const getWindowFromElement = (el: HTMLElement) =>\n el.ownerDocument?.defaultView || null;\n","import { NONE } from '../../constants';\nimport type { TSize } from '../../typedefs';\nimport {\n getDocumentFromElement,\n getWindowFromElement,\n getScrollLeftTop,\n} from '../../util/dom_misc';\n\nexport const setCanvasDimensions = (\n el: HTMLCanvasElement,\n ctx: CanvasRenderingContext2D,\n { width, height }: TSize,\n retinaScaling = 1,\n) => {\n el.width = width;\n el.height = height;\n if (retinaScaling > 1) {\n el.setAttribute('width', (width * retinaScaling).toString());\n el.setAttribute('height', (height * retinaScaling).toString());\n ctx.scale(retinaScaling, retinaScaling);\n }\n};\n\nexport type CSSDimensions = {\n width: number | string;\n height: number | string;\n};\n\nexport const setCSSDimensions = (\n el: HTMLElement,\n { width, height }: Partial,\n) => {\n width && (el.style.width = typeof width === 'number' ? `${width}px` : width);\n height &&\n (el.style.height = typeof height === 'number' ? `${height}px` : height);\n};\n\n/**\n * Returns offset for a given element\n * @param {HTMLElement} element Element to get offset for\n * @return {Object} Object with \"left\" and \"top\" properties\n */\nexport function getElementOffset(element: HTMLElement) {\n const doc = element && getDocumentFromElement(element),\n offset = { left: 0, top: 0 };\n\n if (!doc) {\n return offset;\n }\n const elemStyle: CSSStyleDeclaration =\n getWindowFromElement(element)?.getComputedStyle(element, null) ||\n ({} as CSSStyleDeclaration);\n offset.left += parseInt(elemStyle.borderLeftWidth, 10) || 0;\n offset.top += parseInt(elemStyle.borderTopWidth, 10) || 0;\n offset.left += parseInt(elemStyle.paddingLeft, 10) || 0;\n offset.top += parseInt(elemStyle.paddingTop, 10) || 0;\n\n let box = { left: 0, top: 0 };\n\n const docElem = doc.documentElement;\n if (typeof element.getBoundingClientRect !== 'undefined') {\n box = element.getBoundingClientRect();\n }\n\n const scrollLeftTop = getScrollLeftTop(element);\n\n return {\n left:\n box.left + scrollLeftTop.left - (docElem.clientLeft || 0) + offset.left,\n top: box.top + scrollLeftTop.top - (docElem.clientTop || 0) + offset.top,\n };\n}\n\n/**\n * Makes element unselectable\n * @param {HTMLElement} element Element to make unselectable\n * @return {HTMLElement} Element that was passed in\n */\nexport function makeElementUnselectable(element: HTMLElement) {\n if (typeof element.onselectstart !== 'undefined') {\n element.onselectstart = () => false;\n }\n element.style.userSelect = NONE;\n return element;\n}\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport type { CSSDimensions } from './util';\nimport { setCSSDimensions, getElementOffset } from './util';\nimport { createCanvasElement, isHTMLCanvas } from '../../util/misc/dom';\nimport { setCanvasDimensions } from './util';\nimport { FabricError } from '../../util/internals/console';\n\nexport type CanvasItem = {\n el: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n};\n\nexport class StaticCanvasDOMManager {\n /**\n * Keeps a copy of the canvas style before setting retina scaling and other potions\n * in order to return it to original state on dispose\n * @type string\n */\n private _originalCanvasStyle?: string;\n\n lower: CanvasItem;\n\n constructor(arg0?: string | HTMLCanvasElement) {\n const el = this.createLowerCanvas(arg0);\n this.lower = { el, ctx: el.getContext('2d')! };\n }\n\n protected createLowerCanvas(arg0?: HTMLCanvasElement | string) {\n // canvasEl === 'HTMLCanvasElement' does not work on jsdom/node\n const el = isHTMLCanvas(arg0)\n ? arg0\n : (arg0 &&\n (getFabricDocument().getElementById(arg0) as HTMLCanvasElement)) ||\n createCanvasElement();\n if (el.hasAttribute('data-fabric')) {\n throw new FabricError(\n 'Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?',\n );\n }\n this._originalCanvasStyle = el.style.cssText;\n el.setAttribute('data-fabric', 'main');\n el.classList.add('lower-canvas');\n return el;\n }\n\n cleanupDOM({ width, height }: TSize) {\n const { el } = this.lower;\n // restore canvas style and attributes\n el.classList.remove('lower-canvas');\n el.removeAttribute('data-fabric');\n // restore canvas size to original size in case retina scaling was applied\n el.setAttribute('width', `${width}`);\n el.setAttribute('height', `${height}`);\n el.style.cssText = this._originalCanvasStyle || '';\n this._originalCanvasStyle = undefined;\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n const { el, ctx } = this.lower;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial) {\n setCSSDimensions(this.lower.el, size);\n }\n\n /**\n * Calculates canvas element offset relative to the document\n */\n calcOffset() {\n return getElementOffset(this.lower.el);\n }\n\n dispose() {\n getEnv().dispose(this.lower.el);\n // @ts-expect-error disposing\n delete this.lower;\n }\n}\n","import { iMatrix } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TFiller, TMat2D, TOptions } from '../typedefs';\n\ninterface CanvasDrawableOptions {\n /**\n * if set to false background image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n backgroundVpt: boolean;\n\n /**\n * Background color of canvas instance.\n * @type {(String|TFiller)}\n * @default\n */\n backgroundColor: TFiller | string;\n\n /**\n * Background image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as background, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n backgroundImage?: FabricObject;\n\n /**\n * if set to false overlay image is not affected by viewport transform\n * @since 1.6.3\n * @type Boolean\n * @todo we should really find a different way to do this\n * @default\n */\n overlayVpt: boolean;\n\n /**\n * Overlay color of canvas instance.\n * @since 1.3.9\n * @type {(String|TFiller)}\n * @default\n */\n overlayColor: TFiller | string;\n\n /**\n * Overlay image of canvas instance.\n * since 2.4.0 image caching is active, please when putting an image as overlay, add to the\n * canvas property a reference to the canvas it is on. Otherwise the image cannot detect the zoom\n * vale. As an alternative you can disable image objectCaching\n * @type FabricObject\n * @default\n */\n overlayImage?: FabricObject;\n}\n\ninterface CanvasRenderingOptions {\n /**\n * Indicates whether {@link StaticCanvas#add}, {@link StaticCanvas#insertAt} and {@link StaticCanvas#remove},\n * {@link StaticCanvas#moveTo}, {@link StaticCanvas#clear} and many more, should also re-render canvas.\n * Disabling this option will not give a performance boost when adding/removing a lot of objects to/from canvas at once\n * since the renders are queued and executed one per frame.\n * Disabling is suggested anyway and managing the renders of the app manually is not a big effort ( canvas.requestRenderAll() )\n * Left default to true to do not break documentation and old app, fiddles.\n * @type Boolean\n * @default\n */\n renderOnAddRemove: boolean;\n\n /**\n * Based on vptCoords and object.aCoords, skip rendering of objects that\n * are not included in current viewport.\n * May greatly help in applications with crowded canvas and use of zoom/pan\n * If One of the corner of the bounding box of the object is on the canvas\n * the objects get rendered.\n * @type Boolean\n * @default true\n */\n skipOffscreen: boolean;\n\n /**\n * When true, canvas is scaled by devicePixelRatio for better rendering on retina screens\n * @type Boolean\n * @default\n */\n enableRetinaScaling: boolean;\n\n /**\n * Indicates whether this canvas will use image smoothing, this is on by default in browsers\n * @type Boolean\n * @default\n */\n imageSmoothingEnabled: boolean;\n\n /**\n * a fabricObject that, without stroke define a clipping area with their shape. filled in black\n * the clipPath object gets used when the canvas has rendered, and the context is placed in the\n * top left corner of the canvas.\n * clipPath will clip away controls, if you do not want this to happen use controlsAboveOverlay = true\n * @type FabricObject\n */\n clipPath?: FabricObject;\n}\n\nexport interface CanvasExportOptions {\n /**\n * Indicates whether toObject/toDatalessObject should include default values\n * if set to false, takes precedence over the object value.\n * @type Boolean\n * @default\n */\n includeDefaultValues: boolean;\n\n /**\n * When true, getSvgTransform() will apply the StaticCanvas.viewportTransform to the SVG transformation. When true,\n * a zoomed canvas will then produce zoomed SVG output.\n * @type Boolean\n * @default\n */\n svgViewportTransformation: boolean;\n}\n\nexport interface StaticCanvasOptions\n extends CanvasDrawableOptions,\n CanvasRenderingOptions,\n CanvasExportOptions {\n /**\n * Width in virtual/logical pixels of the canvas.\n * The canvas can be larger than width if retina scaling is active\n * @type number\n */\n width: number;\n\n /**\n * Height in virtual/logical pixels of the canvas.\n * The canvas can be taller than width if retina scaling is active\n * @type height\n */\n height: number;\n\n /**\n * Indicates whether object controls (borders/controls) are rendered above overlay image\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n controlsAboveOverlay: boolean;\n\n /**\n * Indicates whether the browser can be scrolled when using a touchscreen and dragging on the canvas\n * It gives PRIORITY to DOM scrolling, it doesn't make it always possible.\n * If is true, when using a touch event on the canvas, the canvas will scroll if scroll is possible.\n * If we are in drawing mode or if we are selecting an object the canvas preventDefault and so it won't scroll\n * @type Boolean\n * @default\n *\n * @todo move to Canvas\n */\n allowTouchScrolling: boolean;\n\n /**\n * The transformation (a Canvas 2D API transform matrix) which focuses the viewport\n * @type Array\n * @example Default transform\n * canvas.viewportTransform = [1, 0, 0, 1, 0, 0];\n * @example Scale by 70% and translate toward bottom-right by 50, without skewing\n * canvas.viewportTransform = [0.7, 0, 0, 0.7, 50, 50];\n * @default\n */\n viewportTransform: TMat2D;\n}\n\nexport const staticCanvasDefaults: TOptions = {\n backgroundVpt: true,\n backgroundColor: '',\n overlayVpt: true,\n overlayColor: '',\n\n includeDefaultValues: true,\n svgViewportTransformation: true,\n\n renderOnAddRemove: true,\n skipOffscreen: true,\n enableRetinaScaling: true,\n imageSmoothingEnabled: true,\n\n /**\n * @todo move to Canvas\n */\n controlsAboveOverlay: false,\n /**\n * @todo move to Canvas\n */\n allowTouchScrolling: false,\n\n viewportTransform: [...iMatrix],\n};\n","import { config } from '../config';\nimport { CENTER, VERSION } from '../constants';\nimport type { CanvasEvents, StaticCanvasEvents } from '../EventTypeDefs';\nimport type { Gradient } from '../gradient/Gradient';\nimport { createCollectionMixin, isCollection } from '../Collection';\nimport { CommonMethods } from '../CommonMethods';\nimport type { Pattern } from '../Pattern';\nimport { Point } from '../Point';\nimport type { TCachedFabricObject } from '../shapes/Object/Object';\nimport type {\n Abortable,\n Constructor,\n TCornerPoint,\n TDataUrlOptions,\n TFiller,\n TMat2D,\n TSize,\n TSVGReviver,\n TToCanvasElementOptions,\n TValidToObjectMethod,\n TOptions,\n} from '../typedefs';\nimport {\n cancelAnimFrame,\n requestAnimFrame,\n} from '../util/animation/AnimationFrameProvider';\nimport { runningAnimations } from '../util/animation/AnimationRegistry';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor, toDataURL } from '../util/misc/dom';\nimport { invertTransform, transformPoint } from '../util/misc/matrix';\nimport type { EnlivenObjectOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { toFixed } from '../util/misc/toFixed';\nimport { isFiller, isPattern, isTextObject } from '../util/typeAssertions';\nimport { StaticCanvasDOMManager } from './DOMManagers/StaticCanvasDOMManager';\nimport type { CSSDimensions } from './DOMManagers/util';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\nimport { staticCanvasDefaults } from './StaticCanvasOptions';\nimport { log, FabricError } from '../util/internals/console';\nimport { getDevicePixelRatio } from '../env';\n\n/**\n * Having both options in TCanvasSizeOptions set to true transform the call in a calcOffset\n * Better try to restrict with types to avoid confusion.\n */\nexport type TCanvasSizeOptions =\n | {\n backstoreOnly?: true;\n cssOnly?: false;\n }\n | {\n backstoreOnly?: false;\n cssOnly?: true;\n };\n\nexport type TSVGExportOptions = {\n suppressPreamble?: boolean;\n viewBox?: {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n encoding?: 'UTF-8'; // test Encoding type and see what happens\n width?: string;\n height?: string;\n reviver?: TSVGReviver;\n};\n\n/**\n * Static canvas class\n * @see {@link http://fabricjs.com/static_canvas|StaticCanvas demo}\n * @fires before:render\n * @fires after:render\n * @fires canvas:cleared\n * @fires object:added\n * @fires object:removed\n */\n// TODO: fix `EventSpec` inheritance https://github.com/microsoft/TypeScript/issues/26154#issuecomment-1366616260\nexport class StaticCanvas<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends StaticCanvasEvents = StaticCanvasEvents,\n >\n extends createCollectionMixin(CommonMethods)\n implements StaticCanvasOptions\n{\n declare width: number;\n declare height: number;\n\n // background\n declare backgroundVpt: boolean;\n declare backgroundColor: TFiller | string;\n declare backgroundImage?: FabricObject;\n // overlay\n declare overlayVpt: boolean;\n declare overlayColor: TFiller | string;\n declare overlayImage?: FabricObject;\n\n declare clipPath?: FabricObject;\n\n declare includeDefaultValues: boolean;\n\n // rendering config\n declare renderOnAddRemove: boolean;\n declare skipOffscreen: boolean;\n declare enableRetinaScaling: boolean;\n declare imageSmoothingEnabled: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare controlsAboveOverlay: boolean;\n\n /**\n * @todo move to Canvas\n */\n declare allowTouchScrolling: boolean;\n\n declare viewportTransform: TMat2D;\n\n /**\n * The viewport bounding box in scene plane coordinates, see {@link calcViewportBoundaries}\n */\n declare vptCoords: TCornerPoint;\n\n /**\n * A reference to the canvas actual HTMLCanvasElement.\n * Can be use to read the raw pixels, but never write or manipulate\n * @type HTMLCanvasElement\n */\n get lowerCanvasEl() {\n return this.elements.lower?.el;\n }\n\n get contextContainer() {\n return this.elements.lower?.ctx;\n }\n\n /**\n * If true the Canvas is in the process or has been disposed/destroyed.\n * No more rendering operation will be executed on this canvas.\n * @type boolean\n */\n declare destroyed?: boolean;\n\n /**\n * Started the process of disposing but not done yet.\n * WIll likely complete the render cycle already scheduled but stopping adding more.\n * @type boolean\n */\n declare disposed?: boolean;\n\n declare _offset: { left: number; top: number };\n protected declare hasLostContext: boolean;\n protected declare nextRenderHandle: number;\n\n declare elements: StaticCanvasDOMManager;\n\n /**\n * When true control drawing is skipped.\n * This boolean is used to avoid toDataURL to export controls.\n * Usage of this boolean to build up other flows and features is not supported\n * @type Boolean\n * @default false\n */\n protected declare skipControlsDrawing: boolean;\n\n static ownDefaults = staticCanvasDefaults;\n\n // reference to\n protected declare __cleanupTask?: {\n (): void;\n kill: (reason?: any) => void;\n };\n\n static getDefaults(): Record {\n return StaticCanvas.ownDefaults;\n }\n\n constructor(\n el?: string | HTMLCanvasElement,\n options: TOptions = {},\n ) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof StaticCanvas).getDefaults(),\n );\n this.set(options);\n this.initElements(el);\n this._setDimensionsImpl({\n width: this.width || this.elements.lower.el.width || 0,\n height: this.height || this.elements.lower.el.height || 0,\n });\n this.skipControlsDrawing = false;\n this.viewportTransform = [...this.viewportTransform];\n this.calcViewportBoundaries();\n }\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new StaticCanvasDOMManager(el);\n }\n\n add(...objects: FabricObject[]) {\n const size = super.add(...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n insertAt(index: number, ...objects: FabricObject[]) {\n const size = super.insertAt(index, ...objects);\n objects.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return size;\n }\n\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n removed.length > 0 && this.renderOnAddRemove && this.requestRenderAll();\n return removed;\n }\n\n _onObjectAdded(obj: FabricObject) {\n if (obj.canvas && (obj.canvas as StaticCanvas) !== this) {\n log(\n 'warn',\n 'Canvas is trying to add an object that belongs to a different canvas.\\n' +\n 'Resulting to default behavior: removing object from previous canvas and adding to new canvas',\n );\n obj.canvas.remove(obj);\n }\n obj._set('canvas', this);\n obj.setCoords();\n this.fire('object:added', { target: obj });\n obj.fire('added', { target: this });\n }\n\n _onObjectRemoved(obj: FabricObject) {\n obj._set('canvas', undefined);\n this.fire('object:removed', { target: obj });\n obj.fire('removed', { target: this });\n }\n\n _onStackOrderChanged() {\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * @private\n * @see https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/SettingUptheCanvas/SettingUptheCanvas.html\n * @return {Number} retinaScaling if applied, otherwise 1;\n */\n getRetinaScaling() {\n return this.enableRetinaScaling ? getDevicePixelRatio() : 1;\n }\n\n /**\n * Calculates canvas element offset relative to the document\n * This method is also attached as \"resize\" event handler of window\n */\n calcOffset() {\n return (this._offset = this.elements.calcOffset());\n }\n\n /**\n * Returns canvas width (in px)\n * @return {Number}\n */\n getWidth(): number {\n return this.width;\n }\n\n /**\n * Returns canvas height (in px)\n * @return {Number}\n */\n getHeight(): number {\n return this.height;\n }\n\n /**\n * Sets width of this canvas instance\n * @param {Number|String} value Value to set width to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setWidth(\n value: TSize['width'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setWidth(\n value: CSSDimensions['width'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setWidth(value: number, options?: never) {\n return this.setDimensions({ width: value }, options);\n }\n\n /**s\n * Sets height of this canvas instance\n * @param {Number|String} value Value to set height to\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n * @deprecated will be removed in 7.0\n */\n setHeight(\n value: TSize['height'],\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setHeight(\n value: CSSDimensions['height'],\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setHeight(value: CSSDimensions['height'], options?: never) {\n return this.setDimensions({ height: value }, options);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: Partial,\n { cssOnly = false, backstoreOnly = false }: TCanvasSizeOptions = {},\n ) {\n if (!cssOnly) {\n const size = {\n width: this.width,\n height: this.height,\n ...(dimensions as Partial),\n };\n this.elements.setDimensions(size, this.getRetinaScaling());\n this.hasLostContext = true;\n this.width = size.width;\n this.height = size.height;\n }\n if (!backstoreOnly) {\n this.elements.setCSSDimensions(dimensions);\n }\n\n this.calcOffset();\n }\n\n /**\n * Sets dimensions (width, height) of this canvas instance. when options.cssOnly flag active you should also supply the unit of measure (px/%/em)\n * @param {Object} dimensions Object with width/height properties\n * @param {Number|String} [dimensions.width] Width of canvas element\n * @param {Number|String} [dimensions.height] Height of canvas element\n * @param {Object} [options] Options object\n * @param {Boolean} [options.backstoreOnly=false] Set the given dimensions only as canvas backstore dimensions\n * @param {Boolean} [options.cssOnly=false] Set the given dimensions only as css dimensions\n */\n setDimensions(\n dimensions: Partial,\n options?: { cssOnly?: true; backstoreOnly?: false },\n ): void;\n setDimensions(\n dimensions: Partial,\n options?: { backstoreOnly?: true; cssOnly?: false },\n ): void;\n setDimensions(dimensions: Partial, options?: never): void;\n setDimensions(\n dimensions: Partial,\n options?: TCanvasSizeOptions,\n ) {\n this._setDimensionsImpl(dimensions, options);\n if (!options || !options.cssOnly) {\n this.requestRenderAll();\n }\n }\n\n /**\n * Returns canvas zoom level\n * @return {Number}\n */\n getZoom() {\n return this.viewportTransform[0];\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n this.viewportTransform = vpt;\n this.calcViewportBoundaries();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Sets zoom level of this canvas instance, the zoom centered around point\n * meaning that following zoom to point with the same point will have the visual\n * effect of the zoom originating from that point. The point won't move.\n * It has nothing to do with canvas center or visual center of the viewport.\n * @param {Point} point to zoom with respect to\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n zoomToPoint(point: Point, value: number) {\n // TODO: just change the scale, preserve other transformations\n const before = point,\n vpt: TMat2D = [...this.viewportTransform];\n const newPoint = transformPoint(point, invertTransform(vpt));\n vpt[0] = value;\n vpt[3] = value;\n const after = transformPoint(newPoint, vpt);\n vpt[4] += before.x - after.x;\n vpt[5] += before.y - after.y;\n this.setViewportTransform(vpt);\n }\n\n /**\n * Sets zoom level of this canvas instance\n * @param {Number} value to set zoom to, less than 1 zooms out\n */\n setZoom(value: number) {\n this.zoomToPoint(new Point(0, 0), value);\n }\n\n /**\n * Pan viewport so as to place point at top left corner of canvas\n * @param {Point} point to move to\n */\n absolutePan(point: Point) {\n const vpt: TMat2D = [...this.viewportTransform];\n vpt[4] = -point.x;\n vpt[5] = -point.y;\n return this.setViewportTransform(vpt);\n }\n\n /**\n * Pans viewpoint relatively\n * @param {Point} point (position vector) to move by\n */\n relativePan(point: Point) {\n return this.absolutePan(\n new Point(\n -point.x - this.viewportTransform[4],\n -point.y - this.viewportTransform[5],\n ),\n );\n }\n\n /**\n * Returns <canvas> element corresponding to this instance\n * @return {HTMLCanvasElement}\n */\n getElement(): HTMLCanvasElement {\n return this.elements.lower.el;\n }\n\n /**\n * Clears specified context of canvas element\n * @param {CanvasRenderingContext2D} ctx Context to clear\n */\n clearContext(ctx: CanvasRenderingContext2D) {\n ctx.clearRect(0, 0, this.width, this.height);\n }\n\n /**\n * Returns context of canvas where objects are drawn\n * @return {CanvasRenderingContext2D}\n */\n getContext(): CanvasRenderingContext2D {\n return this.elements.lower.ctx;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n this.remove(...this.getObjects());\n this.backgroundImage = undefined;\n this.overlayImage = undefined;\n this.backgroundColor = '';\n this.overlayColor = '';\n this.clearContext(this.getContext());\n this.fire('canvas:cleared');\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Renders the canvas\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n this.renderCanvas(this.getContext(), this._objects);\n }\n\n /**\n * Function created to be instance bound at initialization\n * used in requestAnimationFrame rendering\n * Let the fabricJS call it. If you call it manually you could have more\n * animationFrame stacking on to of each other\n * for an imperative rendering, use canvas.renderAll\n * @private\n */\n renderAndReset() {\n this.nextRenderHandle = 0;\n this.renderAll();\n }\n\n /**\n * Append a renderAll request to next animation frame.\n * unless one is already in progress, in that case nothing is done\n * a boolean flag will avoid appending more.\n */\n requestRenderAll() {\n if (!this.nextRenderHandle && !this.disposed && !this.destroyed) {\n this.nextRenderHandle = requestAnimFrame(() => this.renderAndReset());\n }\n }\n\n /**\n * Calculate the position of the 4 corner of canvas with current viewportTransform.\n * helps to determinate when an object is in the current rendering viewport\n */\n calcViewportBoundaries(): TCornerPoint {\n const width = this.width,\n height = this.height,\n iVpt = invertTransform(this.viewportTransform),\n a = transformPoint({ x: 0, y: 0 }, iVpt),\n b = transformPoint({ x: width, y: height }, iVpt),\n // we don't support vpt flipping\n // but the code is robust enough to mostly work with flipping\n min = a.min(b),\n max = a.max(b);\n return (this.vptCoords = {\n tl: min,\n tr: new Point(max.x, min.y),\n bl: new Point(min.x, max.y),\n br: max,\n });\n }\n\n cancelRequestedRender() {\n if (this.nextRenderHandle) {\n cancelAnimFrame(this.nextRenderHandle);\n this.nextRenderHandle = 0;\n }\n }\n\n drawControls(_ctx: CanvasRenderingContext2D) {\n // Static canvas has no controls\n }\n\n /**\n * Renders background, objects, overlay and controls.\n * @param {CanvasRenderingContext2D} ctx\n * @param {Array} objects to render\n */\n renderCanvas(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n if (this.destroyed) {\n return;\n }\n\n const v = this.viewportTransform,\n path = this.clipPath;\n this.calcViewportBoundaries();\n this.clearContext(ctx);\n ctx.imageSmoothingEnabled = this.imageSmoothingEnabled;\n // @ts-expect-error node-canvas stuff\n ctx.patternQuality = 'best';\n this.fire('before:render', { ctx });\n this._renderBackground(ctx);\n\n ctx.save();\n //apply viewport transform once for all rendering process\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this._renderObjects(ctx, objects);\n ctx.restore();\n if (!this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n if (path) {\n path._set('canvas', this);\n // needed to setup a couple of variables\n // todo migrate to the newer one\n path.shouldCache();\n path._transformDone = true;\n (path as TCachedFabricObject).renderCache({ forClipping: true });\n this.drawClipPathOnCanvas(ctx, path as TCachedFabricObject);\n }\n this._renderOverlay(ctx);\n if (this.controlsAboveOverlay && !this.skipControlsDrawing) {\n this.drawControls(ctx);\n }\n this.fire('after:render', { ctx });\n\n if (this.__cleanupTask) {\n this.__cleanupTask();\n this.__cleanupTask = undefined;\n }\n }\n\n /**\n * Paint the cached clipPath on the lowerCanvasEl\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawClipPathOnCanvas(\n ctx: CanvasRenderingContext2D,\n clipPath: TCachedFabricObject,\n ) {\n const v = this.viewportTransform;\n ctx.save();\n ctx.transform(...v);\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4;\n ctx.globalCompositeOperation = 'destination-in';\n clipPath.transform(ctx);\n ctx.scale(1 / clipPath.zoomX, 1 / clipPath.zoomY);\n ctx.drawImage(\n clipPath._cacheCanvas,\n -clipPath.cacheTranslationX,\n -clipPath.cacheTranslationY,\n );\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} objects to render\n */\n _renderObjects(ctx: CanvasRenderingContext2D, objects: FabricObject[]) {\n for (let i = 0, len = objects.length; i < len; ++i) {\n objects[i] && objects[i].render(ctx);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {string} property 'background' or 'overlay'\n */\n _renderBackgroundOrOverlay(\n ctx: CanvasRenderingContext2D,\n property: 'background' | 'overlay',\n ) {\n const fill = this[`${property}Color`],\n object = this[`${property}Image`],\n v = this.viewportTransform,\n needsVpt = this[`${property}Vpt`];\n if (!fill && !object) {\n return;\n }\n const isAFiller = isFiller(fill);\n if (fill) {\n ctx.save();\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(this.width, 0);\n ctx.lineTo(this.width, this.height);\n ctx.lineTo(0, this.height);\n ctx.closePath();\n ctx.fillStyle = isAFiller ? fill.toLive(ctx /* this */)! : fill;\n if (needsVpt) {\n ctx.transform(...v);\n }\n if (isAFiller) {\n ctx.transform(1, 0, 0, 1, fill.offsetX || 0, fill.offsetY || 0);\n const m = ((fill as Gradient<'linear'>).gradientTransform ||\n (fill as Pattern).patternTransform) as TMat2D;\n m && ctx.transform(...m);\n }\n ctx.fill();\n ctx.restore();\n }\n if (object) {\n ctx.save();\n const { skipOffscreen } = this;\n // if the object doesn't move with the viewport,\n // the offscreen concept does not apply;\n this.skipOffscreen = needsVpt;\n if (needsVpt) {\n ctx.transform(...v);\n }\n object.render(ctx);\n this.skipOffscreen = skipOffscreen;\n ctx.restore();\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'background');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderOverlay(ctx: CanvasRenderingContext2D) {\n this._renderBackgroundOrOverlay(ctx, 'overlay');\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * Returned value is an object with top and left properties\n * @return {Object} object with \"top\" and \"left\" number values\n * @deprecated migrate to `getCenterPoint`\n */\n getCenter() {\n return {\n top: this.height / 2,\n left: this.width / 2,\n };\n }\n\n /**\n * Returns coordinates of a center of canvas.\n * @return {Point}\n */\n getCenterPoint() {\n return new Point(this.width / 2, this.height / 2);\n }\n\n /**\n * Centers object horizontally in the canvas\n */\n centerObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getCenterPoint().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically in the canvas\n * @param {FabricObject} object Object to center vertically\n */\n centerObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object vertically and horizontally in the canvas\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n centerObject(object: FabricObject) {\n return this._centerObject(object, this.getCenterPoint());\n }\n\n /**\n * Centers object vertically and horizontally in the viewport\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObject(object: FabricObject) {\n return this._centerObject(object, this.getVpCenter());\n }\n\n /**\n * Centers object horizontally in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectH(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(this.getVpCenter().x, object.getCenterPoint().y),\n );\n }\n\n /**\n * Centers object Vertically in the viewport, object.top is unchanged\n * @param {FabricObject} object Object to center vertically and horizontally\n */\n viewportCenterObjectV(object: FabricObject) {\n return this._centerObject(\n object,\n new Point(object.getCenterPoint().x, this.getVpCenter().y),\n );\n }\n\n /**\n * Calculate the point in canvas that correspond to the center of actual viewport.\n * @return {Point} vpCenter, viewport center\n */\n getVpCenter(): Point {\n return transformPoint(\n this.getCenterPoint(),\n invertTransform(this.viewportTransform),\n );\n }\n\n /**\n * @private\n * @param {FabricObject} object Object to center\n * @param {Point} center Center point\n */\n _centerObject(object: FabricObject, center: Point) {\n object.setXY(center, CENTER, CENTER);\n object.setCoords();\n this.renderOnAddRemove && this.requestRenderAll();\n }\n\n /**\n * Returns dataless JSON representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {String} json string\n */\n toDatalessJSON(propertiesToInclude?: string[]) {\n return this.toDatalessObject(propertiesToInclude);\n }\n\n /**\n * Returns object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toObject', propertiesToInclude);\n }\n\n /**\n * Returns Object representation of canvas\n * this alias is provided because if you call JSON.stringify on an instance,\n * the toJSON object will be invoked if it exists.\n * Having a toJSON method means you can do JSON.stringify(myCanvas)\n * @return {Object} JSON compatible object\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/pec86/|jsFiddle demo}\n * @example JSON without additional properties\n * var json = canvas.toJSON();\n * @example JSON with additional properties included\n * var json = canvas.toJSON(['lockMovementX', 'lockMovementY', 'lockRotation', 'lockScalingX', 'lockScalingY']);\n * @example JSON without default values\n * var json = canvas.toJSON();\n */\n toJSON() {\n return this.toObject();\n }\n\n /**\n * Returns dataless object representation of canvas\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: string[]) {\n return this._toObjectMethod('toDatalessObject', propertiesToInclude);\n }\n\n /**\n * @private\n */\n _toObjectMethod(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const clipPath = this.clipPath;\n const clipPathData =\n clipPath && !clipPath.excludeFromExport\n ? this._toObject(clipPath, methodName, propertiesToInclude)\n : null;\n return {\n version: VERSION,\n ...pick(this, propertiesToInclude as (keyof this)[]),\n objects: this._objects\n .filter((object) => !object.excludeFromExport)\n .map((instance) =>\n this._toObject(instance, methodName, propertiesToInclude),\n ),\n ...this.__serializeBgOverlay(methodName, propertiesToInclude),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n let originalValue;\n\n if (!this.includeDefaultValues) {\n originalValue = instance.includeDefaultValues;\n instance.includeDefaultValues = false;\n }\n\n const object = instance[methodName](propertiesToInclude);\n if (!this.includeDefaultValues) {\n instance.includeDefaultValues = !!originalValue;\n }\n return object;\n }\n\n /**\n * @private\n */\n __serializeBgOverlay(\n methodName: TValidToObjectMethod,\n propertiesToInclude?: string[],\n ) {\n const data: any = {},\n bgImage = this.backgroundImage,\n overlayImage = this.overlayImage,\n bgColor = this.backgroundColor,\n overlayColor = this.overlayColor;\n\n if (isFiller(bgColor)) {\n if (!bgColor.excludeFromExport) {\n data.background = bgColor.toObject(propertiesToInclude);\n }\n } else if (bgColor) {\n data.background = bgColor;\n }\n\n if (isFiller(overlayColor)) {\n if (!overlayColor.excludeFromExport) {\n data.overlay = overlayColor.toObject(propertiesToInclude);\n }\n } else if (overlayColor) {\n data.overlay = overlayColor;\n }\n\n if (bgImage && !bgImage.excludeFromExport) {\n data.backgroundImage = this._toObject(\n bgImage,\n methodName,\n propertiesToInclude,\n );\n }\n if (overlayImage && !overlayImage.excludeFromExport) {\n data.overlayImage = this._toObject(\n overlayImage,\n methodName,\n propertiesToInclude,\n );\n }\n\n return data;\n }\n\n /* _TO_SVG_START_ */\n\n declare svgViewportTransformation: boolean;\n\n /**\n * Returns SVG representation of canvas\n * @function\n * @param {Object} [options] Options object for SVG output\n * @param {Boolean} [options.suppressPreamble=false] If true xml tag is not included\n * @param {Object} [options.viewBox] SVG viewbox object\n * @param {Number} [options.viewBox.x] x-coordinate of viewbox\n * @param {Number} [options.viewBox.y] y-coordinate of viewbox\n * @param {Number} [options.viewBox.width] Width of viewbox\n * @param {Number} [options.viewBox.height] Height of viewbox\n * @param {String} [options.encoding=UTF-8] Encoding of SVG output\n * @param {String} [options.width] desired width of svg with or without units\n * @param {String} [options.height] desired height of svg with or without units\n * @param {Function} [reviver] Method for further parsing of svg elements, called after each fabric object converted into svg representation.\n * @return {String} SVG string\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#serialization}\n * @see {@link http://jsfiddle.net/fabricjs/jQ3ZZ/|jsFiddle demo}\n * @example Normal SVG output\n * var svg = canvas.toSVG();\n * @example SVG output without preamble (without <?xml ../>)\n * var svg = canvas.toSVG({suppressPreamble: true});\n * @example SVG output with viewBox attribute\n * var svg = canvas.toSVG({\n * viewBox: {\n * x: 100,\n * y: 100,\n * width: 200,\n * height: 300\n * }\n * });\n * @example SVG output with different encoding (default: UTF-8)\n * var svg = canvas.toSVG({encoding: 'ISO-8859-1'});\n * @example Modify SVG output with reviver function\n * var svg = canvas.toSVG(null, function(svg) {\n * return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', '');\n * });\n */\n toSVG(options: TSVGExportOptions = {}, reviver?: TSVGReviver) {\n options.reviver = reviver;\n const markup: string[] = [];\n\n this._setSVGPreamble(markup, options);\n this._setSVGHeader(markup, options);\n if (this.clipPath) {\n markup.push(`\\n`);\n }\n this._setSVGBgOverlayColor(markup, 'background');\n this._setSVGBgOverlayImage(markup, 'backgroundImage', reviver);\n this._setSVGObjects(markup, reviver);\n if (this.clipPath) {\n markup.push('\\n');\n }\n this._setSVGBgOverlayColor(markup, 'overlay');\n this._setSVGBgOverlayImage(markup, 'overlayImage', reviver);\n\n markup.push('');\n\n return markup.join('');\n }\n\n /**\n * @private\n */\n _setSVGPreamble(markup: string[], options: TSVGExportOptions): void {\n if (options.suppressPreamble) {\n return;\n }\n markup.push(\n '\\n',\n '\\n',\n );\n }\n\n /**\n * @private\n */\n _setSVGHeader(markup: string[], options: TSVGExportOptions): void {\n const width = options.width || `${this.width}`,\n height = options.height || `${this.height}`,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS,\n optViewBox = options.viewBox;\n let viewBox: string;\n if (optViewBox) {\n viewBox = `viewBox=\"${optViewBox.x} ${optViewBox.y} ${optViewBox.width} ${optViewBox.height}\" `;\n } else if (this.svgViewportTransformation) {\n const vpt = this.viewportTransform;\n viewBox = `viewBox=\"${toFixed(\n -vpt[4] / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(-vpt[5] / vpt[3], NUM_FRACTION_DIGITS)} ${toFixed(\n this.width / vpt[0],\n NUM_FRACTION_DIGITS,\n )} ${toFixed(this.height / vpt[3], NUM_FRACTION_DIGITS)}\" `;\n } else {\n viewBox = `viewBox=\"0 0 ${this.width} ${this.height}\" `;\n }\n\n markup.push(\n '\\n',\n 'Created with Fabric.js ',\n VERSION,\n '\\n',\n '\\n',\n this.createSVGFontFacesMarkup(),\n this.createSVGRefElementsMarkup(),\n this.createSVGClipPathMarkup(options),\n '\\n',\n );\n }\n\n createSVGClipPathMarkup(options: TSVGExportOptions): string {\n const clipPath = this.clipPath;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n return `\\n${clipPath.toClipPathSVG(\n options.reviver,\n )}\\n`;\n }\n return '';\n }\n\n /**\n * Creates markup containing SVG referenced elements like patterns, gradients etc.\n * @return {String}\n */\n createSVGRefElementsMarkup(): string {\n return (['background', 'overlay'] as const)\n .map((prop) => {\n const fill = this[`${prop}Color`];\n if (isFiller(fill)) {\n const shouldTransform = this[`${prop}Vpt`],\n vpt = this.viewportTransform,\n object = {\n // otherwise circular dependency\n isType: () => false,\n width: this.width / (shouldTransform ? vpt[0] : 1),\n height: this.height / (shouldTransform ? vpt[3] : 1),\n };\n return fill.toSVG(object as FabricObject, {\n additionalTransform: shouldTransform ? matrixToSVG(vpt) : '',\n });\n }\n })\n .join('');\n }\n\n /**\n * Creates markup containing SVG font faces,\n * font URLs for font faces must be collected by developers\n * and are not extracted from the DOM by fabricjs\n * @param {Array} objects Array of fabric objects\n * @return {String}\n */\n createSVGFontFacesMarkup(): string {\n const objects: FabricObject[] = [],\n fontList: Record = {},\n fontPaths = config.fontPaths;\n\n this._objects.forEach(function add(object) {\n objects.push(object);\n if (isCollection(object)) {\n object._objects.forEach(add);\n }\n });\n\n objects.forEach((obj) => {\n if (!isTextObject(obj)) {\n return;\n }\n const { styles, fontFamily } = obj;\n if (fontList[fontFamily] || !fontPaths[fontFamily]) {\n return;\n }\n fontList[fontFamily] = true;\n if (!styles) {\n return;\n }\n Object.values(styles).forEach((styleRow) => {\n Object.values(styleRow).forEach(({ fontFamily = '' }) => {\n if (!fontList[fontFamily] && fontPaths[fontFamily]) {\n fontList[fontFamily] = true;\n }\n });\n });\n });\n\n const fontListMarkup = Object.keys(fontList)\n .map(\n (fontFamily) =>\n `\\t\\t@font-face {\\n\\t\\t\\tfont-family: '${fontFamily}';\\n\\t\\t\\tsrc: url('${fontPaths[fontFamily]}');\\n\\t\\t}\\n`,\n )\n .join('');\n\n if (fontListMarkup) {\n return `\\t\\n`;\n }\n return '';\n }\n\n /**\n * @private\n */\n _setSVGObjects(markup: string[], reviver?: TSVGReviver) {\n this.forEachObject((fabricObject) => {\n if (fabricObject.excludeFromExport) {\n return;\n }\n this._setSVGObject(markup, fabricObject, reviver);\n });\n }\n\n /**\n * This is its own function because the Canvas ( non static ) requires extra code here\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n markup.push(instance.toSVG(reviver));\n }\n\n /**\n * @private\n */\n _setSVGBgOverlayImage(\n markup: string[],\n property: 'overlayImage' | 'backgroundImage',\n reviver?: TSVGReviver,\n ) {\n const bgOrOverlay = this[property];\n if (bgOrOverlay && !bgOrOverlay.excludeFromExport && bgOrOverlay.toSVG) {\n markup.push(bgOrOverlay.toSVG(reviver));\n }\n }\n\n /**\n * @TODO this seems to handle patterns but fail at gradients.\n * @private\n */\n _setSVGBgOverlayColor(markup: string[], property: 'background' | 'overlay') {\n const filler = this[`${property}Color`];\n if (!filler) {\n return;\n }\n if (isFiller(filler)) {\n const repeat = (filler as Pattern).repeat || '',\n finalWidth = this.width,\n finalHeight = this.height,\n shouldInvert = this[`${property}Vpt`],\n additionalTransform = shouldInvert\n ? matrixToSVG(invertTransform(this.viewportTransform))\n : '';\n markup.push(\n `\\n`,\n );\n } else {\n markup.push(\n '\\n',\n );\n }\n }\n /* _TO_SVG_END_ */\n\n /**\n * Populates canvas with data from the specified JSON.\n * JSON format must conform to the one of {@link fabric.Canvas#toJSON}\n *\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n *\n * @param {String|Object} json JSON string or object\n * @param {Function} [reviver] Method for further parsing of JSON elements, called after each fabric object created.\n * @param {Object} [options] options\n * @param {AbortSignal} [options.signal] see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {Promise} instance\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-3#deserialization}\n * @see {@link http://jsfiddle.net/fabricjs/fmgXt/|jsFiddle demo}\n * @example loadFromJSON\n * canvas.loadFromJSON(json).then((canvas) => canvas.requestRenderAll());\n * @example loadFromJSON with reviver\n * canvas.loadFromJSON(json, function(o, object) {\n * // `o` = json object\n * // `object` = fabric.Object instance\n * // ... do some stuff ...\n * }).then((canvas) => {\n * ... canvas is restored, add your code.\n * });\n *\n */\n loadFromJSON(\n json: string | Record,\n reviver?: EnlivenObjectOptions['reviver'],\n { signal }: Abortable = {},\n ): Promise {\n if (!json) {\n return Promise.reject(new FabricError('`json` is undefined'));\n }\n\n // parse json if it wasn't already\n const serialized = typeof json === 'string' ? JSON.parse(json) : json;\n const {\n objects = [],\n backgroundImage,\n background,\n overlayImage,\n overlay,\n clipPath,\n } = serialized;\n const renderOnAddRemove = this.renderOnAddRemove;\n this.renderOnAddRemove = false;\n\n return Promise.all([\n enlivenObjects(objects, {\n reviver,\n signal,\n }),\n enlivenObjectEnlivables(\n {\n backgroundImage,\n backgroundColor: background,\n overlayImage,\n overlayColor: overlay,\n clipPath,\n },\n { signal },\n ),\n ]).then(([enlived, enlivedMap]) => {\n this.clear();\n this.add(...enlived);\n this.set(serialized);\n this.set(enlivedMap);\n this.renderOnAddRemove = renderOnAddRemove;\n return this;\n });\n }\n\n /**\n * Clones canvas instance\n * @param {string[]} [properties] Array of properties to include in the cloned canvas and children\n */\n clone(properties: string[]) {\n const data = this.toObject(properties);\n const canvas = this.cloneWithoutData();\n return canvas.loadFromJSON(data);\n }\n\n /**\n * Clones canvas instance without cloning existing data.\n * This essentially copies canvas dimensions since loadFromJSON does not affect canvas size.\n */\n cloneWithoutData() {\n const el = createCanvasElementFor(this);\n return new (this.constructor as Constructor)(el);\n }\n\n /**\n * Exports canvas element to a dataurl image. Note that when multiplier is used, cropping is scaled appropriately\n * @param {Object} [options] Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by, to have consistent\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 2.0.0\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n * @see {@link https://jsfiddle.net/xsjua1rd/ demo}\n * @example Generate jpeg dataURL with lower quality\n * var dataURL = canvas.toDataURL({\n * format: 'jpeg',\n * quality: 0.8\n * });\n * @example Generate cropped png dataURL (clipping of canvas)\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * left: 100,\n * top: 100,\n * width: 200,\n * height: 200\n * });\n * @example Generate double scaled png dataURL\n * var dataURL = canvas.toDataURL({\n * format: 'png',\n * multiplier: 2\n * });\n * @example Generate dataURL with objects that overlap a specified object\n * var myObject;\n * var dataURL = canvas.toDataURL({\n * filter: (object) => object.isContainedWithinObject(myObject) || object.intersectsWithObject(myObject)\n * });\n */\n toDataURL(options = {} as TDataUrlOptions): string {\n const {\n format = 'png',\n quality = 1,\n multiplier = 1,\n enableRetinaScaling = false,\n } = options;\n const finalMultiplier =\n multiplier * (enableRetinaScaling ? this.getRetinaScaling() : 1);\n\n return toDataURL(\n this.toCanvasElement(finalMultiplier, options),\n format,\n quality,\n );\n }\n\n /**\n * Create a new HTMLCanvas element painted with the current canvas content.\n * No need to resize the actual one or repaint it.\n * Will transfer object ownership to a new canvas, paint it, and set everything back.\n * This is an intermediary step used to get to a dataUrl but also it is useful to\n * create quick image copies of a canvas without passing for the dataUrl string\n * @param {Number} [multiplier] a zoom factor.\n * @param {Object} [options] Cropping informations\n * @param {Number} [options.left] Cropping left offset.\n * @param {Number} [options.top] Cropping top offset.\n * @param {Number} [options.width] Cropping width.\n * @param {Number} [options.height] Cropping height.\n * @param {(object: fabric.Object) => boolean} [options.filter] Function to filter objects.\n */\n toCanvasElement(\n multiplier = 1,\n { width, height, left, top, filter } = {} as TToCanvasElementOptions,\n ): HTMLCanvasElement {\n const scaledWidth = (width || this.width) * multiplier,\n scaledHeight = (height || this.height) * multiplier,\n zoom = this.getZoom(),\n originalWidth = this.width,\n originalHeight = this.height,\n originalSkipControlsDrawing = this.skipControlsDrawing,\n newZoom = zoom * multiplier,\n vp = this.viewportTransform,\n translateX = (vp[4] - (left || 0)) * multiplier,\n translateY = (vp[5] - (top || 0)) * multiplier,\n newVp = [newZoom, 0, 0, newZoom, translateX, translateY] as TMat2D,\n originalRetina = this.enableRetinaScaling,\n canvasEl = createCanvasElementFor({\n width: scaledWidth,\n height: scaledHeight,\n }),\n objectsToRender = filter\n ? this._objects.filter((obj) => filter(obj))\n : this._objects;\n this.enableRetinaScaling = false;\n this.viewportTransform = newVp;\n this.width = scaledWidth;\n this.height = scaledHeight;\n this.skipControlsDrawing = true;\n this.calcViewportBoundaries();\n this.renderCanvas(canvasEl.getContext('2d')!, objectsToRender);\n this.viewportTransform = vp;\n this.width = originalWidth;\n this.height = originalHeight;\n this.calcViewportBoundaries();\n this.enableRetinaScaling = originalRetina;\n this.skipControlsDrawing = originalSkipControlsDrawing;\n return canvasEl;\n }\n\n /**\n * Waits until rendering has settled to destroy the canvas\n * @returns {Promise} a promise resolving to `true` once the canvas has been destroyed or to `false` if the canvas has was already destroyed\n * @throws if aborted by a consequent call\n */\n dispose() {\n !this.disposed &&\n this.elements.cleanupDOM({ width: this.width, height: this.height });\n runningAnimations.cancelByCanvas(this);\n this.disposed = true;\n return new Promise((resolve, reject) => {\n const task = () => {\n this.destroy();\n resolve(true);\n };\n task.kill = reject;\n if (this.__cleanupTask) {\n this.__cleanupTask.kill('aborted');\n }\n\n if (this.destroyed) {\n resolve(false);\n } else if (this.nextRenderHandle) {\n this.__cleanupTask = task;\n } else {\n task();\n }\n });\n }\n\n /**\n * Clears the canvas element, disposes objects and frees resources.\n *\n * Invoked as part of the **async** operation of {@link dispose}.\n *\n * **CAUTION**:\n *\n * This method is **UNSAFE**.\n * You may encounter a race condition using it if there's a requested render.\n * Call this method only if you are sure rendering has settled.\n * Consider using {@link dispose} as it is **SAFE**\n *\n * @private\n */\n destroy() {\n this.destroyed = true;\n this.cancelRequestedRender();\n this.forEachObject((object) => object.dispose());\n this._objects = [];\n if (this.backgroundImage) {\n this.backgroundImage.dispose();\n }\n this.backgroundImage = undefined;\n if (this.overlayImage) {\n this.overlayImage.dispose();\n }\n this.overlayImage = undefined;\n this.elements.dispose();\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String} string representation of an instance\n */\n toString() {\n return `#`;\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport { getScrollLeftTop } from './dom_misc';\n\nconst touchEvents = ['touchstart', 'touchmove', 'touchend'];\n\nfunction getTouchInfo(event: TouchEvent | MouseEvent): MouseEvent | Touch {\n const touchProp = (event as TouchEvent).changedTouches;\n if (touchProp && touchProp[0]) {\n return touchProp[0];\n }\n return event as MouseEvent;\n}\n\nexport const getPointer = (event: TPointerEvent): Point => {\n const element = event.target as HTMLElement,\n scroll = getScrollLeftTop(element),\n _evt = getTouchInfo(event);\n return new Point(_evt.clientX + scroll.left, _evt.clientY + scroll.top);\n};\n\nexport const isTouchEvent = (event: TPointerEvent) =>\n touchEvents.includes(event.type) ||\n (event as PointerEvent).pointerType === 'touch';\n\nexport const stopEvent = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n};\n","import type { XY } from '../../Point';\nimport type { TBBox } from '../../typedefs';\n\n/**\n * Calculates bounding box (left, top, width, height) from given `points`\n * @param {XY[]} points\n * @return {Object} Object with left, top, width, height properties\n */\nexport const makeBoundingBoxFromPoints = (points: XY[]): TBBox => {\n let left = 0,\n top = 0,\n width = 0,\n height = 0;\n\n for (let i = 0, len = points.length; i < len; i++) {\n const { x, y } = points[i];\n if (x > width || !i) width = x;\n if (x < left || !i) left = x;\n if (y > height || !i) height = y;\n if (y < top || !i) top = y;\n }\n\n return {\n left,\n top,\n width: width - left,\n height: height - top,\n };\n};\n","import { Point } from '../../Point';\nimport { CENTER } from '../../constants';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { makeBoundingBoxFromPoints } from './boundingBoxFromPoints';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from './matrix';\n\n/**\n * given an object and a transform, apply the inverse transform to the object,\n * this is equivalent to remove from that object that transformation, so that\n * added in a space with the removed transform, the object will be the same as before.\n * Removing from an object a transform that scale by 2 is like scaling it by 1/2.\n * Removing from an object a transform that rotate by 30deg is like rotating by 30deg\n * in the opposite direction.\n * This util is used to add objects inside transformed groups or nested groups.\n * @param {FabricObject} object the object you want to transform\n * @param {TMat2D} transform the destination transform\n */\nexport const removeTransformFromObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const inverted = invertTransform(transform),\n finalTransform = multiplyTransformMatrices(\n inverted,\n object.calcOwnMatrix(),\n );\n applyTransformToObject(object, finalTransform);\n};\n\n/**\n * given an object and a transform, apply the transform to the object.\n * this is equivalent to change the space where the object is drawn.\n * Adding to an object a transform that scale by 2 is like scaling it by 2.\n * This is used when removing an object from an active selection for example.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const addTransformToObject = (object: FabricObject, transform: TMat2D) =>\n applyTransformToObject(\n object,\n multiplyTransformMatrices(transform, object.calcOwnMatrix()),\n );\n\n/**\n * discard an object transform state and apply the one from the matrix.\n * @param {FabricObject} object the object you want to transform\n * @param {Array} transform the destination transform\n */\nexport const applyTransformToObject = (\n object: FabricObject,\n transform: TMat2D,\n) => {\n const { translateX, translateY, scaleX, scaleY, ...otherOptions } =\n qrDecompose(transform),\n center = new Point(translateX, translateY);\n object.flipX = false;\n object.flipY = false;\n Object.assign(object, otherOptions);\n object.set({ scaleX, scaleY });\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n/**\n * reset an object transform state to neutral. Top and left are not accounted for\n * @param {FabricObject} target object to transform\n */\nexport const resetObjectTransform = (target: FabricObject) => {\n target.scaleX = 1;\n target.scaleY = 1;\n target.skewX = 0;\n target.skewY = 0;\n target.flipX = false;\n target.flipY = false;\n target.rotate(0);\n};\n\n/**\n * Extract Object transform values\n * @param {FabricObject} target object to read from\n * @return {Object} Components of transform\n */\nexport const saveObjectTransform = (target: FabricObject) => ({\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n angle: target.angle,\n left: target.left,\n flipX: target.flipX,\n flipY: target.flipY,\n top: target.top,\n});\n\n/**\n * given a width and height, return the size of the bounding box\n * that can contains the box with width/height with applied transform.\n * Use to calculate the boxes around objects for controls.\n * @param {Number} width\n * @param {Number} height\n * @param {TMat2D} t\n * @returns {Point} size\n */\nexport const sizeAfterTransform = (\n width: number,\n height: number,\n t: TMat2D,\n) => {\n const dimX = width / 2,\n dimY = height / 2,\n points = [\n new Point(-dimX, -dimY),\n new Point(dimX, -dimY),\n new Point(-dimX, dimY),\n new Point(dimX, dimY),\n ].map((p) => p.transform(t)),\n bbox = makeBoundingBoxFromPoints(points);\n return new Point(bbox.width, bbox.height);\n};\n","import { iMatrix } from '../../constants';\nimport type { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/Object';\nimport type { TMat2D } from '../../typedefs';\nimport { invertTransform, multiplyTransformMatrices } from './matrix';\nimport { applyTransformToObject } from './objectTransforms';\n\n/**\n * We are actually looking for the transformation from the destination plane to the source plane (change of basis matrix)\\\n * The object will exist on the destination plane and we want it to seem unchanged by it so we invert the destination matrix (`to`) and then apply the source matrix (`from`)\n * @param [from]\n * @param [to]\n * @returns\n */\nexport const calcPlaneChangeMatrix = (\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n) => multiplyTransformMatrices(invertTransform(to), from);\n\n/**\n * Sends a point from the source coordinate plane to the destination coordinate plane.\\\n * From the canvas/viewer's perspective the point remains unchanged.\n *\n * @example Send point from canvas plane to group plane\n * var obj = new Rect({ left: 20, top: 20, width: 60, height: 60, strokeWidth: 0 });\n * var group = new Group([obj], { strokeWidth: 0 });\n * var sentPoint1 = sendPointToPlane(new Point(50, 50), undefined, group.calcTransformMatrix());\n * var sentPoint2 = sendPointToPlane(new Point(50, 50), iMatrix, group.calcTransformMatrix());\n * console.log(sentPoint1, sentPoint2) // both points print (0,0) which is the center of group\n *\n * @param {Point} point\n * @param {TMat2D} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `point` exists in the canvas coordinate plane.\n * @param {TMat2D} [to] destination plane matrix to contain object. Passing `undefined` means `point` should be sent to the canvas coordinate plane.\n * @returns {Point} transformed point\n */\nexport const sendPointToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to));\n\n/**\n * See {@link sendPointToPlane}\n */\nexport const sendVectorToPlane = (\n point: Point,\n from: TMat2D = iMatrix,\n to: TMat2D = iMatrix,\n): Point => point.transform(calcPlaneChangeMatrix(from, to), true);\n\n/**\n *\n * A util that abstracts applying transform to objects.\\\n * Sends `object` to the destination coordinate plane by applying the relevant transformations.\\\n * Changes the space/plane where `object` is drawn.\\\n * From the canvas/viewer's perspective `object` remains unchanged.\n *\n * @example Move clip path from one object to another while preserving it's appearance as viewed by canvas/viewer\n * let obj, obj2;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * // render\n * sendObjectToPlane(clipPath, obj.calcTransformMatrix(), obj2.calcTransformMatrix());\n * obj.clipPath = undefined;\n * obj2.clipPath = clipPath;\n * // render, clipPath now clips obj2 but seems unchanged from the eyes of the viewer\n *\n * @example Clip an object's clip path with an existing object\n * let obj, existingObj;\n * let clipPath = new Circle({ radius: 50 });\n * obj.clipPath = clipPath;\n * let transformTo = multiplyTransformMatrices(obj.calcTransformMatrix(), clipPath.calcTransformMatrix());\n * sendObjectToPlane(existingObj, existingObj.group?.calcTransformMatrix(), transformTo);\n * clipPath.clipPath = existingObj;\n *\n * @param {FabricObject} object\n * @param {Matrix} [from] plane matrix containing object. Passing `undefined` is equivalent to passing the identity matrix, which means `object` is a direct child of canvas.\n * @param {Matrix} [to] destination plane matrix to contain object. Passing `undefined` means `object` should be sent to the canvas coordinate plane.\n * @returns {Matrix} the transform matrix that was applied to `object`\n */\nexport const sendObjectToPlane = (\n object: FabricObject,\n from?: TMat2D,\n to?: TMat2D,\n): TMat2D => {\n const t = calcPlaneChangeMatrix(from, to);\n applyTransformToObject(\n object,\n multiplyTransformMatrices(t, object.calcOwnMatrix()),\n );\n return t;\n};\n","import type {\n ObjectModificationEvents,\n TModificationEvents,\n} from '../EventTypeDefs';\n\nexport const fireEvent = (\n eventName: TModificationEvents,\n options: ObjectModificationEvents[typeof eventName],\n) => {\n const {\n transform: { target },\n } = options;\n target.canvas?.fire(`object:${eventName}`, {\n ...options,\n target,\n });\n target.fire(eventName, options);\n};\n","import type { TOriginX, TOriginY } from '../../typedefs';\n\nconst originOffset = {\n left: -0.5,\n top: -0.5,\n center: 0,\n bottom: 0.5,\n right: 0.5,\n};\n/**\n * Resolves origin value relative to center\n * @private\n * @param {TOriginX | TOriginY} originValue originX / originY\n * @returns number\n */\n\nexport const resolveOrigin = (\n originValue: TOriginX | TOriginY | number,\n): number =>\n typeof originValue === 'string'\n ? originOffset[originValue]\n : originValue - 0.5;\n","import type {\n TPointerEvent,\n Transform,\n TransformAction,\n BasicTransformEvent,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TOriginX, TOriginY } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\nimport { CENTER } from '../constants';\n\nexport const NOT_ALLOWED_CURSOR = 'not-allowed';\n\n/**\n * @param {Boolean} alreadySelected true if target is already selected\n * @param {String} corner a string representing the corner ml, mr, tl ...\n * @param {Event} e Event object\n * @param {FabricObject} [target] inserted back to help overriding. Unused\n */\nexport const getActionFromCorner = (\n alreadySelected: boolean,\n corner: string | undefined,\n e: TPointerEvent,\n target: FabricObject,\n) => {\n if (!corner || !alreadySelected) {\n return 'drag';\n }\n const control = target.controls[corner];\n return control.getActionName(e, control, target);\n};\n\n/**\n * Checks if transform is centered\n * @param {Object} transform transform data\n * @return {Boolean} true if transform is centered\n */\nexport function isTransformCentered(transform: Transform) {\n return (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) &&\n resolveOrigin(transform.originY) === resolveOrigin(CENTER)\n );\n}\n\nexport function invertOrigin(origin: TOriginX | TOriginY) {\n return -resolveOrigin(origin) + 0.5;\n}\n\nexport const isLocked = (\n target: FabricObject,\n lockingKey:\n | 'lockMovementX'\n | 'lockMovementY'\n | 'lockRotation'\n | 'lockScalingX'\n | 'lockScalingY'\n | 'lockSkewingX'\n | 'lockSkewingY'\n | 'lockScalingFlip',\n) => target[lockingKey];\n\nexport const commonEventInfo: TransformAction<\n Transform,\n BasicTransformEvent\n> = (eventData, transform, x, y) => {\n return {\n e: eventData,\n transform,\n pointer: new Point(x, y),\n };\n};\n\n/**\n * Combine control position and object angle to find the control direction compared\n * to the object center.\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n * @param {Control} control the control class\n * @return {Number} 0 - 7 a quadrant number\n */\nexport function findCornerQuadrant(\n fabricObject: FabricObject,\n control: Control,\n): number {\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle(),\n cornerAngle =\n angle + radiansToDegrees(Math.atan2(control.y, control.x)) + 360;\n return Math.round((cornerAngle % 360) / 45);\n}\n\n/**\n * @returns the normalized point (rotated relative to center) in local coordinates\n */\nfunction normalizePoint(\n target: FabricObject,\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n): Point {\n const center = target.getRelativeCenterPoint(),\n p =\n typeof originX !== 'undefined' && typeof originY !== 'undefined'\n ? target.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n )\n : new Point(target.left, target.top),\n p2 = target.angle\n ? point.rotate(-degreesToRadians(target.angle), center)\n : point;\n return p2.subtract(p);\n}\n\n/**\n * Transforms a point to the offset from the given origin\n * @param {Object} transform\n * @param {String} originX\n * @param {String} originY\n * @param {number} x\n * @param {number} y\n * @return {Fabric.Point} the normalized point\n */\nexport function getLocalPoint(\n { target, corner }: Transform,\n originX: TOriginX,\n originY: TOriginY,\n x: number,\n y: number,\n) {\n const control = target.controls[corner],\n zoom = target.canvas?.getZoom() || 1,\n padding = target.padding / zoom,\n localPoint = normalizePoint(target, new Point(x, y), originX, originY);\n if (localPoint.x >= padding) {\n localPoint.x -= padding;\n }\n if (localPoint.x <= -padding) {\n localPoint.x += padding;\n }\n if (localPoint.y >= padding) {\n localPoint.y -= padding;\n }\n if (localPoint.y <= padding) {\n localPoint.y += padding;\n }\n localPoint.x -= control.offsetX;\n localPoint.y -= control.offsetY;\n return localPoint;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { LEFT, TOP, MOVING } from '../constants';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo, isLocked } from './util';\n\n/**\n * Action handler\n * @private\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if the translation occurred\n */\nexport const dragHandler: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const { target, offsetX, offsetY } = transform,\n newLeft = x - offsetX,\n newTop = y - offsetY,\n moveX = !isLocked(target, 'lockMovementX') && target.left !== newLeft,\n moveY = !isLocked(target, 'lockMovementY') && target.top !== newTop;\n moveX && target.set(LEFT, newLeft);\n moveY && target.set(TOP, newTop);\n if (moveX || moveY) {\n fireEvent(MOVING, commonEventInfo(eventData, transform, x, y));\n }\n return moveX || moveY;\n};\n","import type { TSVGReviver } from '../../typedefs';\nimport { uid } from '../../util/internals/uid';\nimport { colorPropToSVG, matrixToSVG } from '../../util/misc/svgParsing';\nimport { FILL, NONE, STROKE } from '../../constants';\nimport type { FabricObject } from './FabricObject';\nimport { isFiller } from '../../util/typeAssertions';\n\nexport class FabricObjectSVGExportMixin {\n /**\n * When an object is being exported as SVG as a clippath, a reference inside the SVG is needed.\n * This reference is a UID in the fabric namespace and is temporary stored here.\n * @type {String}\n */\n declare clipPathId?: string;\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(\n this: FabricObjectSVGExportMixin & FabricObject,\n skipShadow?: boolean,\n ) {\n const fillRule = this.fillRule ? this.fillRule : 'nonzero',\n strokeWidth = this.strokeWidth ? this.strokeWidth : '0',\n strokeDashArray = this.strokeDashArray\n ? this.strokeDashArray.join(' ')\n : NONE,\n strokeDashOffset = this.strokeDashOffset ? this.strokeDashOffset : '0',\n strokeLineCap = this.strokeLineCap ? this.strokeLineCap : 'butt',\n strokeLineJoin = this.strokeLineJoin ? this.strokeLineJoin : 'miter',\n strokeMiterLimit = this.strokeMiterLimit ? this.strokeMiterLimit : '4',\n opacity = typeof this.opacity !== 'undefined' ? this.opacity : '1',\n visibility = this.visible ? '' : ' visibility: hidden;',\n filter = skipShadow ? '' : this.getSvgFilter(),\n fill = colorPropToSVG(FILL, this.fill),\n stroke = colorPropToSVG(STROKE, this.stroke);\n\n return [\n stroke,\n 'stroke-width: ',\n strokeWidth,\n '; ',\n 'stroke-dasharray: ',\n strokeDashArray,\n '; ',\n 'stroke-linecap: ',\n strokeLineCap,\n '; ',\n 'stroke-dashoffset: ',\n strokeDashOffset,\n '; ',\n 'stroke-linejoin: ',\n strokeLineJoin,\n '; ',\n 'stroke-miterlimit: ',\n strokeMiterLimit,\n '; ',\n fill,\n 'fill-rule: ',\n fillRule,\n '; ',\n 'opacity: ',\n opacity,\n ';',\n filter,\n visibility,\n ].join('');\n }\n\n /**\n * Returns filter for svg shadow\n * @return {String}\n */\n getSvgFilter(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.shadow ? `filter: url(#SVGID_${this.shadow.id});` : '';\n }\n\n /**\n * Returns id attribute for svg output\n * @return {String}\n */\n getSvgCommons(\n this: FabricObjectSVGExportMixin & FabricObject & { id?: string },\n ) {\n return [\n this.id ? `id=\"${this.id}\" ` : '',\n this.clipPath\n ? `clip-path=\"url(#${\n (this.clipPath as FabricObjectSVGExportMixin & FabricObject)\n .clipPathId\n })\" `\n : '',\n ].join('');\n }\n\n /**\n * Returns transform-string for svg-export\n * @param {Boolean} use the full transform or the single object one.\n * @return {String}\n */\n getSvgTransform(\n this: FabricObjectSVGExportMixin & FabricObject,\n full?: boolean,\n additionalTransform = '',\n ) {\n const transform = full ? this.calcTransformMatrix() : this.calcOwnMatrix(),\n svgTransform = `transform=\"${matrixToSVG(transform)}`;\n return `${svgTransform}${additionalTransform}\" `;\n }\n\n /**\n * Returns svg representation of an instance\n * This function is implemented in each subclass\n * This is just because typescript otherwise cryies all the time\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(_reviver?: TSVGReviver): string[] {\n return [''];\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return this._createBaseSVGMarkup(this._toSVG(reviver), {\n reviver,\n });\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(\n this: FabricObjectSVGExportMixin & FabricObject,\n reviver?: TSVGReviver,\n ) {\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(reviver), {\n reviver,\n })\n );\n }\n\n /**\n * @private\n */\n _createBaseClipPathSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n reviver,\n additionalTransform = '',\n }: { reviver?: TSVGReviver; additionalTransform?: string } = {},\n ) {\n const commonPieces = [\n this.getSvgTransform(true, additionalTransform),\n this.getSvgCommons(),\n ].join(''),\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n objectMarkup[index] = commonPieces;\n return reviver ? reviver(objectMarkup.join('')) : objectMarkup.join('');\n }\n\n /**\n * @private\n */\n _createBaseSVGMarkup(\n this: FabricObjectSVGExportMixin & FabricObject,\n objectMarkup: string[],\n {\n noStyle,\n reviver,\n withShadow,\n additionalTransform,\n }: {\n noStyle?: boolean;\n reviver?: TSVGReviver;\n withShadow?: boolean;\n additionalTransform?: string;\n } = {},\n ): string {\n const styleInfo = noStyle ? '' : `style=\"${this.getSvgStyles()}\" `,\n shadowInfo = withShadow ? `style=\"${this.getSvgFilter()}\" ` : '',\n clipPath = this.clipPath as FabricObjectSVGExportMixin & FabricObject,\n vectorEffect = this.strokeUniform\n ? 'vector-effect=\"non-scaling-stroke\" '\n : '',\n absoluteClipPath = clipPath && clipPath.absolutePositioned,\n stroke = this.stroke,\n fill = this.fill,\n shadow = this.shadow,\n markup = [],\n // insert commons in the markup, style and svgCommons\n index = objectMarkup.indexOf('COMMON_PARTS');\n let clipPathMarkup;\n if (clipPath) {\n clipPath.clipPathId = `CLIPPATH_${uid()}`;\n clipPathMarkup = `\\n${clipPath.toClipPathSVG(reviver)}\\n`;\n }\n if (absoluteClipPath) {\n markup.push('\\n');\n }\n markup.push(\n '\\n',\n );\n const commonPieces = [\n styleInfo,\n vectorEffect,\n noStyle ? '' : this.addPaintOrder(),\n ' ',\n additionalTransform ? `transform=\"${additionalTransform}\" ` : '',\n ].join('');\n objectMarkup[index] = commonPieces;\n if (isFiller(fill)) {\n markup.push(fill.toSVG(this));\n }\n if (isFiller(stroke)) {\n markup.push(stroke.toSVG(this));\n }\n if (shadow) {\n markup.push(shadow.toSVG(this));\n }\n if (clipPath) {\n markup.push(clipPathMarkup);\n }\n markup.push(objectMarkup.join(''));\n markup.push('\\n');\n absoluteClipPath && markup.push('\\n');\n return reviver ? reviver(markup.join('')) : markup.join('');\n }\n\n addPaintOrder(this: FabricObjectSVGExportMixin & FabricObject) {\n return this.paintFirst !== FILL ? ` paint-order=\"${this.paintFirst}\" ` : '';\n }\n}\n","export function getSvgRegex(arr: string[]) {\n return new RegExp('^(' + arr.join('|') + ')\\\\b', 'i');\n}\n","import { getSvgRegex } from './getSvgRegex';\nimport { LEFT, TOP } from '../constants';\n\nexport const reNum = String.raw`(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)`;\n\nexport const svgNS = 'http://www.w3.org/2000/svg';\n\nexport const reFontDeclaration = new RegExp(\n '(normal|italic)?\\\\s*(normal|small-caps)?\\\\s*' +\n '(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\\\s*(' +\n reNum +\n '(?:px|cm|mm|em|pt|pc|in)*)(?:\\\\/(normal|' +\n reNum +\n '))?\\\\s+(.*)',\n);\n\nexport const svgValidTagNames = [\n 'path',\n 'circle',\n 'polygon',\n 'polyline',\n 'ellipse',\n 'rect',\n 'line',\n 'image',\n 'text',\n ],\n svgViewBoxElements = ['symbol', 'image', 'marker', 'pattern', 'view', 'svg'],\n svgInvalidAncestors = [\n 'pattern',\n 'defs',\n 'symbol',\n 'metadata',\n 'clipPath',\n 'mask',\n 'desc',\n ],\n svgValidParents = ['symbol', 'g', 'a', 'svg', 'clipPath', 'defs'],\n attributesMap = {\n cx: LEFT,\n x: LEFT,\n r: 'radius',\n cy: TOP,\n y: TOP,\n display: 'visible',\n visibility: 'visible',\n transform: 'transformMatrix',\n 'fill-opacity': 'fillOpacity',\n 'fill-rule': 'fillRule',\n 'font-family': 'fontFamily',\n 'font-size': 'fontSize',\n 'font-style': 'fontStyle',\n 'font-weight': 'fontWeight',\n 'letter-spacing': 'charSpacing',\n 'paint-order': 'paintFirst',\n 'stroke-dasharray': 'strokeDashArray',\n 'stroke-dashoffset': 'strokeDashOffset',\n 'stroke-linecap': 'strokeLineCap',\n 'stroke-linejoin': 'strokeLineJoin',\n 'stroke-miterlimit': 'strokeMiterLimit',\n 'stroke-opacity': 'strokeOpacity',\n 'stroke-width': 'strokeWidth',\n 'text-decoration': 'textDecoration',\n 'text-anchor': 'textAnchor',\n opacity: 'opacity',\n 'clip-path': 'clipPath',\n 'clip-rule': 'clipRule',\n 'vector-effect': 'strokeUniform',\n 'image-rendering': 'imageSmoothing',\n },\n fSize = 'font-size',\n cPath = 'clip-path';\n\nexport const svgValidTagNamesRegEx = getSvgRegex(svgValidTagNames);\n\nexport const svgViewBoxElementsRegEx = getSvgRegex(svgViewBoxElements);\n\nexport const svgValidParentsRegEx = getSvgRegex(svgValidParents);\n\n// http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute\n// matches, e.g.: +14.56e-12, etc.\nexport const reViewBoxAttrValue = new RegExp(\n '^' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*,?' +\n '\\\\s*(' +\n reNum +\n '+)\\\\s*' +\n '$',\n);\n","import type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n\nconst unitVectorX = new Point(1, 0);\nconst zero = new Point();\n\n/**\n * Rotates `vector` with `radians`\n * @param {Point} vector The vector to rotate (x and y)\n * @param {Number} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotateVector = (vector: Point, radians: TRadian) =>\n vector.rotate(radians);\n\n/**\n * Creates a vector from points represented as a point\n *\n * @param {Point} from\n * @param {Point} to\n * @returns {Point} vector\n */\nexport const createVector = (from: XY, to: XY): Point =>\n new Point(to).subtract(from);\n\n/**\n * return the magnitude of a vector\n * @return {number}\n */\nexport const magnitude = (point: Point) => point.distanceFrom(zero);\n\n/**\n * Calculates the angle between 2 vectors\n * @param {Point} a\n * @param {Point} b\n * @returns the angle in radians from `a` to `b`\n */\nexport const calcAngleBetweenVectors = (a: Point, b: Point): TRadian =>\n Math.atan2(crossProduct(a, b), dotProduct(a, b)) as TRadian;\n\n/**\n * Calculates the angle between the x axis and the vector\n * @param {Point} v\n * @returns the angle in radians of `v`\n */\nexport const calcVectorRotation = (v: Point) =>\n calcAngleBetweenVectors(unitVectorX, v);\n\n/**\n * @param {Point} v\n * @returns {Point} vector representing the unit vector pointing to the direction of `v`\n */\nexport const getUnitVector = (v: Point): Point =>\n v.eq(zero) ? v : v.scalarDivide(magnitude(v));\n\n/**\n * @param {Point} v\n * @param {Boolean} [counterClockwise] the direction of the orthogonal vector, defaults to `true`\n * @returns {Point} the unit orthogonal vector\n */\nexport const getOrthonormalVector = (\n v: Point,\n counterClockwise = true,\n): Point =>\n getUnitVector(new Point(-v.y, v.x).scalarMultiply(counterClockwise ? 1 : -1));\n\n/**\n * Cross product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number} the magnitude of Z vector\n */\nexport const crossProduct = (a: Point, b: Point): number =>\n a.x * b.y - a.y * b.x;\n\n/**\n * Dot product of two vectors in 2D\n * @param {Point} a\n * @param {Point} b\n * @returns {number}\n */\nexport const dotProduct = (a: Point, b: Point): number => a.x * b.x + a.y * b.y;\n\n/**\n * Checks if the vector is between two others. It is considered\n * to be inside when the vector to be tested is between the\n * initial vector and the final vector (included) in a counterclockwise direction.\n * @param {Point} t vector to be tested\n * @param {Point} a initial vector\n * @param {Point} b final vector\n * @returns {boolean} true if the vector is among the others\n */\nexport const isBetweenVectors = (t: Point, a: Point, b: Point): boolean => {\n if (t.eq(a) || t.eq(b)) return true;\n const AxB = crossProduct(a, b),\n AxT = crossProduct(a, t),\n BxT = crossProduct(b, t);\n return AxB >= 0 ? AxT >= 0 && BxT <= 0 : !(AxT <= 0 && BxT >= 0);\n};\n","import { classRegistry } from './ClassRegistry';\nimport { Color } from './color/Color';\nimport { config } from './config';\nimport { reNum } from './parser/constants';\nimport { Point } from './Point';\nimport type { FabricObject } from './shapes/Object/FabricObject';\nimport type { TClassProperties } from './typedefs';\nimport { uid } from './util/internals/uid';\nimport { pickBy } from './util/misc/pick';\nimport { degreesToRadians } from './util/misc/radiansDegreesConversion';\nimport { toFixed } from './util/misc/toFixed';\nimport { rotateVector } from './util/misc/vectors';\n\n/**\n * Regex matching shadow offsetX, offsetY and blur (ex: \"2px 2px 10px rgba(0,0,0,0.2)\", \"rgb(0,255,0) 2px 2px\")\n * - (?:\\s|^): This part captures either a whitespace character (\\s) or the beginning of a line (^). It's non-capturing (due to (?:...)), meaning it doesn't create a capturing group.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: This captures the first component of the shadow, which is the horizontal offset. Breaking it down:\n * - (-?\\d+): Captures an optional minus sign followed by one or more digits (integer part of the number).\n * - (?:\\.\\d*)?: Optionally captures a decimal point followed by zero or more digits (decimal part of the number).\n * - (?:px)?: Optionally captures the \"px\" unit.\n * - (?:\\s?|$): Captures either an optional whitespace or the end of the line. This whole part is wrapped in a non-capturing group and marked as optional with ?.\n * - (-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?: Similar to the previous step, this captures the vertical offset.\n\n(\\d+(?:\\.\\d*)?(?:px)?)?: This captures the blur radius. It's similar to the horizontal offset but without the optional minus sign.\n\n(?:\\s+(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?){0,1}: This captures an optional part for the color. It allows for whitespace followed by a component with an optional minus sign, digits, decimal point, and \"px\" unit.\n\n(?:$|\\s): This captures either the end of the line or a whitespace character. It ensures that the match ends either at the end of the string or with a whitespace character.\n */\n// eslint-disable-next-line max-len\n\nconst shadowOffsetRegex = '(-?\\\\d+(?:\\\\.\\\\d*)?(?:px)?(?:\\\\s?|$))?';\n\nconst reOffsetsAndBlur = new RegExp(\n '(?:\\\\s|^)' +\n shadowOffsetRegex +\n shadowOffsetRegex +\n '(' +\n reNum +\n '?(?:px)?)?(?:\\\\s?|$)(?:$|\\\\s)',\n);\n\nexport const shadowDefaultValues: Partial> = {\n color: 'rgb(0,0,0)',\n blur: 0,\n offsetX: 0,\n offsetY: 0,\n affectStroke: false,\n includeDefaultValues: true,\n nonScaling: false,\n};\n\nexport type SerializedShadowOptions = {\n color: string;\n blur: number;\n offsetX: number;\n offsetY: number;\n affectStroke: boolean;\n nonScaling: boolean;\n type: string;\n};\n\nexport class Shadow {\n /**\n * Shadow color\n * @type String\n * @default\n */\n declare color: string;\n\n /**\n * Shadow blur\n * @type Number\n */\n declare blur: number;\n\n /**\n * Shadow horizontal offset\n * @type Number\n * @default\n */\n declare offsetX: number;\n\n /**\n * Shadow vertical offset\n * @type Number\n * @default\n */\n declare offsetY: number;\n\n /**\n * Whether the shadow should affect stroke operations\n * @type Boolean\n * @default\n */\n declare affectStroke: boolean;\n\n /**\n * Indicates whether toObject should include default values\n * @type Boolean\n * @default\n */\n declare includeDefaultValues: boolean;\n\n /**\n * When `false`, the shadow will scale with the object.\n * When `true`, the shadow's offsetX, offsetY, and blur will not be affected by the object's scale.\n * default to false\n * @type Boolean\n * @default\n */\n declare nonScaling: boolean;\n\n declare id: number;\n\n static ownDefaults = shadowDefaultValues;\n\n static type = 'shadow';\n\n /**\n * @see {@link http://fabricjs.com/shadows|Shadow demo}\n * @param {Object|String} [options] Options object with any of color, blur, offsetX, offsetY properties or string (e.g. \"rgba(0,0,0,0.2) 2px 2px 10px\")\n */\n constructor(options: Partial>);\n constructor(svgAttribute: string);\n constructor(arg0: string | Partial>) {\n const options: Partial> =\n typeof arg0 === 'string' ? Shadow.parseShadow(arg0) : arg0;\n Object.assign(this, Shadow.ownDefaults, options);\n this.id = uid();\n }\n\n /**\n * @param {String} value Shadow value to parse\n * @return {Object} Shadow object with color, offsetX, offsetY and blur\n */\n static parseShadow(value: string) {\n const shadowStr = value.trim(),\n [, offsetX = 0, offsetY = 0, blur = 0] = (\n reOffsetsAndBlur.exec(shadowStr) || []\n ).map((value) => parseFloat(value) || 0),\n color = (shadowStr.replace(reOffsetsAndBlur, '') || 'rgb(0,0,0)').trim();\n\n return {\n color,\n offsetX,\n offsetY,\n blur,\n };\n }\n\n /**\n * Returns a string representation of an instance\n * @see http://www.w3.org/TR/css-text-decor-3/#text-shadow\n * @return {String} Returns CSS3 text-shadow declaration\n */\n toString() {\n return [this.offsetX, this.offsetY, this.blur, this.color].join('px ');\n }\n\n /**\n * Returns SVG representation of a shadow\n * @param {FabricObject} object\n * @return {String} SVG representation of a shadow\n */\n toSVG(object: FabricObject) {\n const offset = rotateVector(\n new Point(this.offsetX, this.offsetY),\n degreesToRadians(-object.angle),\n ),\n BLUR_BOX = 20,\n color = new Color(this.color);\n let fBoxX = 40,\n fBoxY = 40;\n\n if (object.width && object.height) {\n //http://www.w3.org/TR/SVG/filters.html#FilterEffectsRegion\n // we add some extra space to filter box to contain the blur ( 20 )\n fBoxX =\n toFixed(\n (Math.abs(offset.x) + this.blur) / object.width,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n fBoxY =\n toFixed(\n (Math.abs(offset.y) + this.blur) / object.height,\n config.NUM_FRACTION_DIGITS,\n ) *\n 100 +\n BLUR_BOX;\n }\n if (object.flipX) {\n offset.x *= -1;\n }\n if (object.flipY) {\n offset.y *= -1;\n }\n\n return `\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\n\\t\\t\\n\\t\\t\\n\\t\\n\\n`;\n }\n\n /**\n * Returns object representation of a shadow\n * @return {Object} Object representation of a shadow instance\n */\n toObject() {\n const data: SerializedShadowOptions = {\n color: this.color,\n blur: this.blur,\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n affectStroke: this.affectStroke,\n nonScaling: this.nonScaling,\n type: (this.constructor as typeof Shadow).type,\n };\n const defaults = Shadow.ownDefaults as SerializedShadowOptions;\n return !this.includeDefaultValues\n ? pickBy(data, (value, key) => value !== defaults[key])\n : data;\n }\n\n static async fromObject(options: Partial>) {\n return new this(options);\n }\n}\n\nclassRegistry.setClass(Shadow, 'shadow');\n","export const capValue = (min: number, value: number, max: number) =>\n Math.max(min, Math.min(value, max));\n","import {\n TOP,\n LEFT,\n SCALE_Y,\n SCALE_X,\n SKEW_X,\n SKEW_Y,\n FILL,\n STROKE,\n} from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { InteractiveFabricObject } from './InteractiveObject';\nimport type { FabricObject } from './Object';\n\nexport const stateProperties = [\n TOP,\n LEFT,\n SCALE_X,\n SCALE_Y,\n 'flipX',\n 'flipY',\n 'originX',\n 'originY',\n 'angle',\n 'opacity',\n 'globalCompositeOperation',\n 'shadow',\n 'visible',\n SKEW_X,\n SKEW_Y,\n];\n\nexport const cacheProperties = [\n FILL,\n STROKE,\n 'strokeWidth',\n 'strokeDashArray',\n 'width',\n 'height',\n 'paintFirst',\n 'strokeUniform',\n 'strokeLineCap',\n 'strokeDashOffset',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'backgroundColor',\n 'clipPath',\n];\n\nexport const fabricObjectDefaultValues: Partial<\n TClassProperties\n> = {\n // see composeMatrix() to see order of transforms. First defaults listed based on this\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n angle: 0,\n flipX: false,\n flipY: false,\n scaleX: 1,\n scaleY: 1,\n minScaleLimit: 0,\n skewX: 0,\n skewY: 0,\n originX: LEFT,\n originY: TOP,\n strokeWidth: 1,\n strokeUniform: false,\n padding: 0,\n opacity: 1,\n paintFirst: FILL,\n fill: 'rgb(0,0,0)',\n fillRule: 'nonzero',\n stroke: null,\n strokeDashArray: null,\n strokeDashOffset: 0,\n strokeLineCap: 'butt',\n strokeLineJoin: 'miter',\n strokeMiterLimit: 4,\n globalCompositeOperation: 'source-over',\n backgroundColor: '',\n shadow: null,\n visible: true,\n includeDefaultValues: true,\n excludeFromExport: false,\n objectCaching: true,\n clipPath: undefined,\n inverted: false,\n absolutePositioned: false,\n centeredRotation: true,\n centeredScaling: false,\n dirty: true,\n} as const;\n\nexport const interactiveObjectDefaultValues: Partial<\n TClassProperties\n> = {\n noScaleCache: true,\n lockMovementX: false,\n lockMovementY: false,\n lockRotation: false,\n lockScalingX: false,\n lockScalingY: false,\n lockSkewingX: false,\n lockSkewingY: false,\n lockScalingFlip: false,\n cornerSize: 13,\n touchCornerSize: 24,\n transparentCorners: true,\n cornerColor: 'rgb(178,204,255)',\n cornerStrokeColor: '',\n cornerStyle: 'rect',\n cornerDashArray: null,\n hasControls: true,\n borderColor: 'rgb(178,204,255)',\n borderDashArray: null,\n borderOpacityWhenMoving: 0.4,\n borderScaleFactor: 1,\n hasBorders: true,\n selectionBackgroundColor: '',\n selectable: true,\n evented: true,\n perPixelTargetFind: false,\n activeOn: 'down',\n hoverCursor: null,\n moveCursor: null,\n};\n","/**\n * Easing functions\n * @see {@link http://gizma.com/easing/ Easing Equations by Robert Penner}\n */\n\nimport { twoMathPi, halfPI } from '../../constants';\nimport type { TEasingFunction } from './types';\n\nconst normalize = (a: number, c: number, p: number, s: number) => {\n if (a < Math.abs(c)) {\n a = c;\n s = p / 4;\n } else {\n //handle the 0/0 case:\n if (c === 0 && a === 0) {\n s = (p / twoMathPi) * Math.asin(1);\n } else {\n s = (p / twoMathPi) * Math.asin(c / a);\n }\n }\n return { a, c, p, s };\n};\n\nconst elastic = (\n a: number,\n s: number,\n p: number,\n t: number,\n d: number,\n): number =>\n a * Math.pow(2, 10 * (t -= 1)) * Math.sin(((t * d - s) * twoMathPi) / p);\n\n/**\n * Default sinusoidal easing\n */\nexport const defaultEasing: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Cubic easing in\n */\nexport const easeInCubic: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 3 + b;\n\n/**\n * Cubic easing out\n */\nexport const easeOutCubic: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 3 + 1) + b;\n\n/**\n * Cubic easing in and out\n */\nexport const easeInOutCubic: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 3 + b;\n }\n return (c / 2) * ((t - 2) ** 3 + 2) + b;\n};\n\n/**\n * Quartic easing in\n */\nexport const easeInQuart: TEasingFunction = (t, b, c, d) =>\n c * (t /= d) * t ** 3 + b;\n\n/**\n * Quartic easing out\n */\nexport const easeOutQuart: TEasingFunction = (t, b, c, d) =>\n -c * ((t = t / d - 1) * t ** 3 - 1) + b;\n\n/**\n * Quartic easing in and out\n */\nexport const easeInOutQuart: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 4 + b;\n }\n return (-c / 2) * ((t -= 2) * t ** 3 - 2) + b;\n};\n\n/**\n * Quintic easing in\n */\nexport const easeInQuint: TEasingFunction = (t, b, c, d) =>\n c * (t / d) ** 5 + b;\n\n/**\n * Quintic easing out\n */\nexport const easeOutQuint: TEasingFunction = (t, b, c, d) =>\n c * ((t / d - 1) ** 5 + 1) + b;\n\n/**\n * Quintic easing in and out\n */\nexport const easeInOutQuint: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 5 + b;\n }\n return (c / 2) * ((t - 2) ** 5 + 2) + b;\n};\n\n/**\n * Sinusoidal easing in\n */\nexport const easeInSine: TEasingFunction = (t, b, c, d) =>\n -c * Math.cos((t / d) * halfPI) + c + b;\n\n/**\n * Sinusoidal easing out\n */\nexport const easeOutSine: TEasingFunction = (t, b, c, d) =>\n c * Math.sin((t / d) * halfPI) + b;\n\n/**\n * Sinusoidal easing in and out\n */\nexport const easeInOutSine: TEasingFunction = (t, b, c, d) =>\n (-c / 2) * (Math.cos((Math.PI * t) / d) - 1) + b;\n\n/**\n * Exponential easing in\n */\nexport const easeInExpo: TEasingFunction = (t, b, c, d) =>\n t === 0 ? b : c * 2 ** (10 * (t / d - 1)) + b;\n\n/**\n * Exponential easing out\n */\nexport const easeOutExpo: TEasingFunction = (t, b, c, d) =>\n t === d ? b + c : c * -(2 ** ((-10 * t) / d) + 1) + b;\n\n/**\n * Exponential easing in and out\n */\nexport const easeInOutExpo: TEasingFunction = (t, b, c, d) => {\n if (t === 0) {\n return b;\n }\n if (t === d) {\n return b + c;\n }\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * 2 ** (10 * (t - 1)) + b;\n }\n return (c / 2) * -(2 ** (-10 * --t) + 2) + b;\n};\n\n/**\n * Circular easing in\n */\nexport const easeInCirc: TEasingFunction = (t, b, c, d) =>\n -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;\n\n/**\n * Circular easing out\n */\nexport const easeOutCirc: TEasingFunction = (t, b, c, d) =>\n c * Math.sqrt(1 - (t = t / d - 1) * t) + b;\n\n/**\n * Circular easing in and out\n */\nexport const easeInOutCirc: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (-c / 2) * (Math.sqrt(1 - t ** 2) - 1) + b;\n }\n return (c / 2) * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;\n};\n\n/**\n * Elastic easing in\n */\nexport const easeInElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP } = normalize(a, c, p, s);\n return -elastic(normA, normS, normP, t, d) + b;\n};\n\n/**\n * Elastic easing out\n */\nexport const easeOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d;\n if (t === 1) {\n return b + c;\n }\n if (!p) {\n p = d * 0.3;\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n return (\n normA * 2 ** (-10 * t) * Math.sin(((t * d - normS) * twoMathPi) / normP) +\n normC +\n b\n );\n};\n\n/**\n * Elastic easing in and out\n */\nexport const easeInOutElastic: TEasingFunction = (t, b, c, d) => {\n const s = 1.70158,\n a = c;\n let p = 0;\n if (t === 0) {\n return b;\n }\n t /= d / 2;\n if (t === 2) {\n return b + c;\n }\n if (!p) {\n p = d * (0.3 * 1.5);\n }\n const { a: normA, s: normS, p: normP, c: normC } = normalize(a, c, p, s);\n if (t < 1) {\n return -0.5 * elastic(normA, normS, normP, t, d) + b;\n }\n return (\n normA *\n Math.pow(2, -10 * (t -= 1)) *\n Math.sin(((t * d - normS) * twoMathPi) / normP) *\n 0.5 +\n normC +\n b\n );\n};\n\n/**\n * Backwards easing in\n */\nexport const easeInBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * (t /= d) * t * ((s + 1) * t - s) + b;\n\n/**\n * Backwards easing out\n */\nexport const easeOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) =>\n c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;\n\n/**\n * Backwards easing in and out\n */\nexport const easeInOutBack: TEasingFunction = (t, b, c, d, s = 1.70158) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;\n }\n return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;\n};\n\n/**\n * Bouncing easing out\n */\nexport const easeOutBounce: TEasingFunction = (t, b, c, d) => {\n if ((t /= d) < 1 / 2.75) {\n return c * (7.5625 * t * t) + b;\n } else if (t < 2 / 2.75) {\n return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;\n } else if (t < 2.5 / 2.75) {\n return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;\n } else {\n return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;\n }\n};\n\n/**\n * Bouncing easing in\n */\nexport const easeInBounce: TEasingFunction = (t, b, c, d) =>\n c - easeOutBounce(d - t, 0, c, d) + b;\n\n/**\n * Bouncing easing in and out\n */\nexport const easeInOutBounce: TEasingFunction = (t, b, c, d) =>\n t < d / 2\n ? easeInBounce(t * 2, 0, c, d) * 0.5 + b\n : easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;\n\n/**\n * Quadratic easing in\n */\nexport const easeInQuad: TEasingFunction = (t, b, c, d) => c * (t /= d) * t + b;\n\n/**\n * Quadratic easing out\n */\nexport const easeOutQuad: TEasingFunction = (t, b, c, d) =>\n -c * (t /= d) * (t - 2) + b;\n\n/**\n * Quadratic easing in and out\n */\nexport const easeInOutQuad: TEasingFunction = (t, b, c, d) => {\n t /= d / 2;\n if (t < 1) {\n return (c / 2) * t ** 2 + b;\n }\n return (-c / 2) * (--t * (t - 2) - 1) + b;\n};\n","import { noop } from '../../constants';\nimport { requestAnimFrame } from './AnimationFrameProvider';\nimport { runningAnimations } from './AnimationRegistry';\nimport { defaultEasing } from './easing';\nimport type {\n AnimationState,\n TAbortCallback,\n TBaseAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultAbort = () => false;\n\nexport abstract class AnimationBase<\n T extends number | number[] = number | number[],\n> {\n declare readonly startValue: T;\n declare readonly endValue: T;\n declare readonly duration: number;\n declare readonly delay: number;\n\n protected declare readonly byValue: T;\n protected declare readonly easing: TEasingFunction;\n\n private declare readonly _onStart: VoidFunction;\n private declare readonly _onChange: TOnAnimationChangeCallback;\n private declare readonly _onComplete: TOnAnimationChangeCallback;\n private declare readonly _abort: TAbortCallback;\n\n /**\n * Used to register the animation to a target object\n * so that it can be cancelled within the object context\n */\n declare readonly target?: unknown;\n\n private _state: AnimationState = 'pending';\n /**\n * Time %, or the ratio of `timeElapsed / duration`\n * @see tick\n */\n durationProgress = 0;\n /**\n * Value %, or the ratio of `(currentValue - startValue) / (endValue - startValue)`\n */\n valueProgress = 0;\n /**\n * Current value\n */\n declare value: T;\n /**\n * Animation start time ms\n */\n private declare startTime: number;\n\n constructor({\n startValue,\n byValue,\n duration = 500,\n delay = 0,\n easing = defaultEasing,\n onStart = noop,\n onChange = noop,\n onComplete = noop,\n abort = defaultAbort,\n target,\n }: TBaseAnimationOptions) {\n this.tick = this.tick.bind(this);\n\n this.duration = duration;\n this.delay = delay;\n this.easing = easing;\n this._onStart = onStart;\n this._onChange = onChange;\n this._onComplete = onComplete;\n this._abort = abort;\n this.target = target;\n\n this.startValue = startValue;\n this.byValue = byValue;\n this.value = this.startValue;\n this.endValue = Object.freeze(this.calculate(this.duration).value);\n }\n\n get state() {\n return this._state;\n }\n\n isDone() {\n return this._state === 'aborted' || this._state === 'completed';\n }\n\n /**\n * Calculate the current value based on the easing parameters\n * @param timeElapsed in ms\n * @protected\n */\n protected abstract calculate(timeElapsed: number): {\n value: T;\n valueProgress: number;\n };\n\n start() {\n const firstTick: FrameRequestCallback = (timestamp) => {\n if (this._state !== 'pending') return;\n this.startTime = timestamp || +new Date();\n this._state = 'running';\n this._onStart();\n this.tick(this.startTime);\n };\n\n this.register();\n\n // setTimeout(cb, 0) will run cb on the next frame, causing a delay\n // we don't want that\n if (this.delay > 0) {\n setTimeout(() => requestAnimFrame(firstTick), this.delay);\n } else {\n requestAnimFrame(firstTick);\n }\n }\n\n private tick(t: number) {\n const durationMs = (t || +new Date()) - this.startTime;\n const boundDurationMs = Math.min(durationMs, this.duration);\n this.durationProgress = boundDurationMs / this.duration;\n const { value, valueProgress } = this.calculate(boundDurationMs);\n this.value = Object.freeze(value);\n this.valueProgress = valueProgress;\n\n if (this._state === 'aborted') {\n return;\n } else if (\n this._abort(this.value, this.valueProgress, this.durationProgress)\n ) {\n this._state = 'aborted';\n this.unregister();\n } else if (durationMs >= this.duration) {\n this.durationProgress = this.valueProgress = 1;\n this._onChange(this.endValue, this.valueProgress, this.durationProgress);\n this._state = 'completed';\n this._onComplete(\n this.endValue,\n this.valueProgress,\n this.durationProgress,\n );\n this.unregister();\n } else {\n this._onChange(this.value, this.valueProgress, this.durationProgress);\n requestAnimFrame(this.tick);\n }\n }\n\n private register() {\n runningAnimations.push(this as unknown as AnimationBase);\n }\n\n private unregister() {\n runningAnimations.remove(this as unknown as AnimationBase);\n }\n\n abort() {\n this._state = 'aborted';\n this.unregister();\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ValueAnimationOptions } from './types';\n\nexport class ValueAnimation extends AnimationBase {\n constructor({\n startValue = 0,\n endValue = 100,\n ...otherOptions\n }: ValueAnimationOptions) {\n super({\n ...otherOptions,\n startValue,\n byValue: endValue - startValue,\n });\n }\n\n protected calculate(timeElapsed: number) {\n const value = this.easing(\n timeElapsed,\n this.startValue,\n this.byValue,\n this.duration,\n );\n return {\n value,\n valueProgress: Math.abs((value - this.startValue) / this.byValue),\n };\n }\n}\n","import { AnimationBase } from './AnimationBase';\nimport type { ArrayAnimationOptions } from './types';\n\nexport class ArrayAnimation extends AnimationBase {\n constructor({\n startValue = [0],\n endValue = [100],\n ...options\n }: ArrayAnimationOptions) {\n super({\n ...options,\n startValue,\n byValue: endValue.map((value, i) => value - startValue[i]),\n });\n }\n protected calculate(timeElapsed: number) {\n const values = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n );\n return {\n value: values,\n valueProgress: Math.abs(\n (values[0] - this.startValue[0]) / this.byValue[0],\n ),\n };\n }\n}\n","import { Color } from '../../color/Color';\nimport type { TRGBAColorSource } from '../../color/typedefs';\nimport { halfPI } from '../../constants';\nimport { capValue } from '../misc/capValue';\nimport { AnimationBase } from './AnimationBase';\nimport type {\n ColorAnimationOptions,\n TEasingFunction,\n TOnAnimationChangeCallback,\n} from './types';\n\nconst defaultColorEasing: TEasingFunction = (\n timeElapsed,\n startValue,\n byValue,\n duration,\n) => {\n const durationProgress = 1 - Math.cos((timeElapsed / duration) * halfPI);\n return startValue + byValue * durationProgress;\n};\n\nconst wrapColorCallback = (\n callback?: TOnAnimationChangeCallback,\n) =>\n callback &&\n ((rgba: TRGBAColorSource, valueProgress: number, durationProgress: number) =>\n callback(new Color(rgba).toRgba(), valueProgress, durationProgress));\n\nexport class ColorAnimation extends AnimationBase {\n constructor({\n startValue,\n endValue,\n easing = defaultColorEasing,\n onChange,\n onComplete,\n abort,\n ...options\n }: ColorAnimationOptions) {\n const startColor = new Color(startValue).getSource();\n const endColor = new Color(endValue).getSource();\n super({\n ...options,\n startValue: startColor,\n byValue: endColor.map(\n (value, i) => value - startColor[i],\n ) as TRGBAColorSource,\n easing,\n onChange: wrapColorCallback(onChange),\n onComplete: wrapColorCallback(onComplete),\n abort: wrapColorCallback(abort),\n });\n }\n protected calculate(timeElapsed: number) {\n const [r, g, b, a] = this.startValue.map((value, i) =>\n this.easing(timeElapsed, value, this.byValue[i], this.duration, i),\n ) as TRGBAColorSource;\n const value = [\n ...[r, g, b].map(Math.round),\n capValue(0, a, 1),\n ] as TRGBAColorSource;\n return {\n value,\n valueProgress:\n // to correctly calculate the change ratio we must find a changed value\n value\n .map((p, i) =>\n this.byValue[i] !== 0\n ? Math.abs((p - this.startValue[i]) / this.byValue[i])\n : 0,\n )\n .find((p) => p !== 0) || 0,\n };\n }\n}\n","import { ValueAnimation } from './ValueAnimation';\nimport { ArrayAnimation } from './ArrayAnimation';\nimport { ColorAnimation } from './ColorAnimation';\nimport type {\n ValueAnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n} from './types';\nimport type { TColorArg } from '../../color/typedefs';\n\nexport type TAnimation =\n T extends TColorArg\n ? ColorAnimation\n : T extends number[]\n ? ArrayAnimation\n : ValueAnimation;\n\nconst isArrayAnimation = (\n options: ArrayAnimationOptions | ValueAnimationOptions,\n): options is ArrayAnimationOptions => {\n return Array.isArray(options.startValue) || Array.isArray(options.endValue);\n};\n\n/**\n * Changes value(s) from startValue to endValue within a certain period of time,\n * invoking callbacks as the value(s) change.\n *\n * @example\n * animate({\n * startValue: 1,\n * endValue: 0,\n * onChange: (v) => {\n * obj.set('opacity', v);\n * // since we are running in a requested frame we should call `renderAll` and not `requestRenderAll`\n * canvas.renderAll();\n * }\n * });\n *\n * @example Using lists:\n * animate({\n * startValue: [1, 2, 3],\n * endValue: [2, 4, 6],\n * onChange: ([x, y, zoom]) => {\n * canvas.zoomToPoint(new Point(x, y), zoom);\n * canvas.renderAll();\n * }\n * });\n *\n */\nexport function animate(options: ArrayAnimationOptions): ArrayAnimation;\nexport function animate(options: ValueAnimationOptions): ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n>(\n options: T,\n): T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation;\nexport function animate<\n T extends ValueAnimationOptions | ArrayAnimationOptions,\n R extends T extends ArrayAnimationOptions ? ArrayAnimation : ValueAnimation,\n>(options: T): R {\n const animation = (\n isArrayAnimation(options)\n ? new ArrayAnimation(options)\n : new ValueAnimation(options)\n ) as R;\n animation.start();\n return animation;\n}\n\nexport function animateColor(options: ColorAnimationOptions) {\n const animation = new ColorAnimation(options);\n animation.start();\n return animation;\n}\n","import { Point } from './Point';\nimport { createVector } from './util/misc/vectors';\n\n/* Adaptation of work of Kevin Lindsey (kevin@kevlindev.com) */\n\nexport type IntersectionType = 'Intersection' | 'Coincident' | 'Parallel';\n\nexport class Intersection {\n declare points: Point[];\n\n declare status?: IntersectionType;\n\n constructor(status?: IntersectionType) {\n this.status = status;\n this.points = [];\n }\n\n /**\n * Used to verify if a point is alredy in the collection\n * @param {Point} point\n * @returns {boolean}\n */\n private includes(point: Point): boolean {\n return this.points.some((p) => p.eq(point));\n }\n\n /**\n * Appends points of intersection\n * @param {...Point[]} points\n * @return {Intersection} thisArg\n * @chainable\n */\n private append(...points: Point[]): Intersection {\n this.points = this.points.concat(\n points.filter((point) => {\n return !this.includes(point);\n }),\n );\n return this;\n }\n\n /**\n * check if point T is on the segment or line defined between A and B\n *\n * @param {Point} T the point we are checking for\n * @param {Point} A one extremity of the segment\n * @param {Point} B the other extremity of the segment\n * @param [infinite] if true checks if `T` is on the line defined by `A` and `B`\n * @returns true if `T` is contained\n */\n static isPointContained(T: Point, A: Point, B: Point, infinite = false) {\n if (A.eq(B)) {\n // Edge case: the segment is a point, we check for coincidence,\n // infinite param has no meaning because there are infinite lines to consider\n return T.eq(A);\n } else if (A.x === B.x) {\n // Edge case: horizontal line.\n // we first check if T.x has the same value, and then if T.y is contained between A.y and B.y\n return (\n T.x === A.x &&\n (infinite || (T.y >= Math.min(A.y, B.y) && T.y <= Math.max(A.y, B.y)))\n );\n } else if (A.y === B.y) {\n // Edge case: vertical line.\n // we first check if T.y has the same value, and then if T.x is contained between A.x and B.x\n return (\n T.y === A.y &&\n (infinite || (T.x >= Math.min(A.x, B.x) && T.x <= Math.max(A.x, B.x)))\n );\n } else {\n // Generic case: sloped line.\n // we check that AT has the same slope as AB\n // for the segment case we need both the vectors to have the same direction and for AT to be lte AB in size\n // for the infinite case we check the absolute value of the slope, since direction is meaningless\n const AB = createVector(A, B);\n const AT = createVector(A, T);\n const s = AT.divide(AB);\n return infinite\n ? Math.abs(s.x) === Math.abs(s.y)\n : s.x === s.y && s.x >= 0 && s.x <= 1;\n }\n }\n\n /**\n * Use the ray casting algorithm to determine if {@link point} is in the polygon defined by {@link points}\n * @see https://en.wikipedia.org/wiki/Point_in_polygon\n * @param point\n * @param points polygon points\n * @returns\n */\n static isPointInPolygon(point: Point, points: Point[]) {\n const other = new Point(point).setX(\n Math.min(point.x - 1, ...points.map((p) => p.x)),\n );\n let hits = 0;\n for (let index = 0; index < points.length; index++) {\n const inter = this.intersectSegmentSegment(\n // polygon side\n points[index],\n points[(index + 1) % points.length],\n // ray\n point,\n other,\n );\n if (inter.includes(point)) {\n // point is on the polygon side\n return true;\n }\n hits += Number(inter.status === 'Intersection');\n }\n return hits % 2 === 1;\n }\n\n /**\n * Checks if a line intersects another\n * @see {@link https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection line intersection}\n * @see {@link https://en.wikipedia.org/wiki/Cramer%27s_rule Cramer's rule}\n * @static\n * @param {Point} a1\n * @param {Point} a2\n * @param {Point} b1\n * @param {Point} b2\n * @param {boolean} [aInfinite=true] check segment intersection by passing `false`\n * @param {boolean} [bInfinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLineLine(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n aInfinite = true,\n bInfinite = true,\n ): Intersection {\n const a2xa1x = a2.x - a1.x,\n a2ya1y = a2.y - a1.y,\n b2xb1x = b2.x - b1.x,\n b2yb1y = b2.y - b1.y,\n a1xb1x = a1.x - b1.x,\n a1yb1y = a1.y - b1.y,\n uaT = b2xb1x * a1yb1y - b2yb1y * a1xb1x,\n ubT = a2xa1x * a1yb1y - a2ya1y * a1xb1x,\n uB = b2yb1y * a2xa1x - b2xb1x * a2ya1y;\n if (uB !== 0) {\n const ua = uaT / uB,\n ub = ubT / uB;\n if (\n (aInfinite || (0 <= ua && ua <= 1)) &&\n (bInfinite || (0 <= ub && ub <= 1))\n ) {\n return new Intersection('Intersection').append(\n new Point(a1.x + ua * a2xa1x, a1.y + ua * a2ya1y),\n );\n } else {\n return new Intersection();\n }\n } else {\n if (uaT === 0 || ubT === 0) {\n const segmentsCoincide =\n aInfinite ||\n bInfinite ||\n Intersection.isPointContained(a1, b1, b2) ||\n Intersection.isPointContained(a2, b1, b2) ||\n Intersection.isPointContained(b1, a1, a2) ||\n Intersection.isPointContained(b2, a1, a2);\n return new Intersection(segmentsCoincide ? 'Coincident' : undefined);\n } else {\n return new Intersection('Parallel');\n }\n }\n }\n\n /**\n * Checks if a segment intersects a line\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} s1 boundary point of segment\n * @param {Point} s2 other boundary point of segment\n * @param {Point} l1 point on line\n * @param {Point} l2 other point on line\n * @return {Intersection}\n */\n static intersectSegmentLine(\n s1: Point,\n s2: Point,\n l1: Point,\n l2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(s1, s2, l1, l2, false, true);\n }\n\n /**\n * Checks if a segment intersects another\n * @see {@link intersectLineLine} for line intersection\n * @static\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point} b1 boundary point of segment\n * @param {Point} b2 other boundary point of segment\n * @return {Intersection}\n */\n static intersectSegmentSegment(\n a1: Point,\n a2: Point,\n b1: Point,\n b2: Point,\n ): Intersection {\n return Intersection.intersectLineLine(a1, a2, b1, b2, false, false);\n }\n\n /**\n * Checks if line intersects polygon\n *\n * @todo account for stroke\n *\n * @static\n * @see {@link intersectSegmentPolygon} for segment intersection\n * @param {Point} a1 point on line\n * @param {Point} a2 other point on line\n * @param {Point[]} points polygon points\n * @param {boolean} [infinite=true] check segment intersection by passing `false`\n * @return {Intersection}\n */\n static intersectLinePolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n infinite = true,\n ): Intersection {\n const result = new Intersection();\n const length = points.length;\n\n for (let i = 0, b1, b2, inter; i < length; i++) {\n b1 = points[i];\n b2 = points[(i + 1) % length];\n inter = Intersection.intersectLineLine(a1, a2, b1, b2, infinite, false);\n if (inter.status === 'Coincident') {\n return inter;\n }\n result.append(...inter.points);\n }\n\n if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if segment intersects polygon\n * @static\n * @see {@link intersectLinePolygon} for line intersection\n * @param {Point} a1 boundary point of segment\n * @param {Point} a2 other boundary point of segment\n * @param {Point[]} points polygon points\n * @return {Intersection}\n */\n static intersectSegmentPolygon(\n a1: Point,\n a2: Point,\n points: Point[],\n ): Intersection {\n return Intersection.intersectLinePolygon(a1, a2, points, false);\n }\n\n /**\n * Checks if polygon intersects another polygon\n *\n * @todo account for stroke\n *\n * @static\n * @param {Point[]} points1\n * @param {Point[]} points2\n * @return {Intersection}\n */\n static intersectPolygonPolygon(\n points1: Point[],\n points2: Point[],\n ): Intersection {\n const result = new Intersection(),\n length = points1.length;\n const coincidences: Intersection[] = [];\n\n for (let i = 0; i < length; i++) {\n const a1 = points1[i],\n a2 = points1[(i + 1) % length],\n inter = Intersection.intersectSegmentPolygon(a1, a2, points2);\n if (inter.status === 'Coincident') {\n coincidences.push(inter);\n result.append(a1, a2);\n } else {\n result.append(...inter.points);\n }\n }\n\n if (coincidences.length > 0 && coincidences.length === points1.length) {\n return new Intersection('Coincident');\n } else if (result.points.length > 0) {\n result.status = 'Intersection';\n }\n\n return result;\n }\n\n /**\n * Checks if polygon intersects rectangle\n * @static\n * @see {@link intersectPolygonPolygon} for polygon intersection\n * @param {Point[]} points polygon points\n * @param {Point} r1 top left point of rect\n * @param {Point} r2 bottom right point of rect\n * @return {Intersection}\n */\n static intersectPolygonRectangle(\n points: Point[],\n r1: Point,\n r2: Point,\n ): Intersection {\n const min = r1.min(r2),\n max = r1.max(r2),\n topRight = new Point(max.x, min.y),\n bottomLeft = new Point(min.x, max.y);\n\n return Intersection.intersectPolygonPolygon(points, [\n min,\n topRight,\n max,\n bottomLeft,\n ]);\n }\n}\n","import type {\n TBBox,\n TCornerPoint,\n TDegree,\n TMat2D,\n TOriginX,\n TOriginY,\n} from '../../typedefs';\nimport { SCALE_X, SCALE_Y, iMatrix } from '../../constants';\nimport { Intersection } from '../../Intersection';\nimport { Point } from '../../Point';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n createRotateMatrix,\n createTranslateMatrix,\n composeMatrix,\n invertTransform,\n multiplyTransformMatrices,\n transformPoint,\n calcPlaneRotation,\n} from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { StaticCanvas } from '../../canvas/StaticCanvas';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type { ControlProps } from './types/ControlProps';\nimport { resolveOrigin } from '../../util/misc/resolveOrigin';\nimport type { Group } from '../Group';\nimport { calcDimensionsMatrix } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport { CommonMethods } from '../../CommonMethods';\nimport type { BaseProps } from './types/BaseProps';\nimport type { FillStrokeProps } from './types/FillStrokeProps';\nimport { CENTER, LEFT, TOP } from '../../constants';\n\ntype TMatrixCache = {\n key: number[];\n value: TMat2D;\n};\n\ntype TACoords = TCornerPoint;\n\nexport class ObjectGeometry\n extends CommonMethods\n implements\n Pick,\n BaseProps,\n Pick\n{\n // #region Geometry\n\n declare padding: number;\n\n /**\n * Describe object's corner position in scene coordinates.\n * The coordinates are derived from the following:\n * left, top, width, height, scaleX, scaleY, skewX, skewY, angle, strokeWidth.\n * The coordinates do not depend on viewport changes.\n * The coordinates get updated with {@link setCoords}.\n * You can calculate them without updating with {@link calcACoords()}\n */\n declare aCoords: TACoords;\n\n /**\n * storage cache for object transform matrix\n */\n declare ownMatrixCache?: TMatrixCache;\n\n /**\n * storage cache for object full transform matrix\n */\n declare matrixCache?: TMatrixCache;\n\n /**\n * A Reference of the Canvas where the object is actually added\n * @type StaticCanvas | Canvas;\n * @default undefined\n * @private\n */\n declare canvas?: StaticCanvas | Canvas;\n\n /**\n * @returns {number} x position according to object's {@link originX} property in canvas coordinate plane\n */\n getX(): number {\n return this.getXY().x;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in canvas coordinate plane\n */\n setX(value: number) {\n this.setXY(this.getXY().setX(value));\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in canvas coordinate plane\n */\n getY(): number {\n return this.getXY().y;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in canvas coordinate plane\n */\n setY(value: number) {\n this.setXY(this.getXY().setY(value));\n }\n\n /**\n * @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getX}\n */\n getRelativeX(): number {\n return this.left;\n }\n\n /**\n * @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\\\n * if parent is canvas then this method is identical to {@link setX}\n */\n setRelativeX(value: number) {\n this.left = value;\n }\n\n /**\n * @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link getY}\n */\n getRelativeY(): number {\n return this.top;\n }\n\n /**\n * @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\\\n * if parent is canvas then this property is identical to {@link setY}\n */\n setRelativeY(value: number) {\n this.top = value;\n }\n\n /**\n * @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane\n */\n getXY(): Point {\n const relativePosition = this.getRelativeXY();\n return this.group\n ? transformPoint(relativePosition, this.group.calcTransformMatrix())\n : relativePosition;\n }\n\n /**\n * Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.\n * You can specify {@link originX} and {@link originY} values,\n * that otherwise are the object's current values.\n * @example Set object's bottom left corner to point (5,5) on canvas\n * object.setXY(new Point(5, 5), 'left', 'bottom').\n * @param {Point} point position in scene coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setXY(point: Point, originX?: TOriginX, originY?: TOriginY) {\n if (this.group) {\n point = transformPoint(\n point,\n invertTransform(this.group.calcTransformMatrix()),\n );\n }\n this.setRelativeXY(point, originX, originY);\n }\n\n /**\n * @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n */\n getRelativeXY(): Point {\n return new Point(this.left, this.top);\n }\n\n /**\n * As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)\n * @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane\n * @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'\n */\n setRelativeXY(\n point: Point,\n originX: TOriginX = this.originX,\n originY: TOriginY = this.originY,\n ) {\n this.setPositionByOrigin(point, originX, originY);\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return false;\n }\n\n /**\n * @return {Point[]} [tl, tr, br, bl] in the scene plane\n */\n getCoords(): Point[] {\n const { tl, tr, br, bl } =\n this.aCoords || (this.aCoords = this.calcACoords());\n const coords = [tl, tr, br, bl];\n if (this.group) {\n const t = this.group.calcTransformMatrix();\n return coords.map((p) => transformPoint(p, t));\n }\n return coords;\n }\n\n /**\n * Checks if object intersects with the scene rect formed by {@link tl} and {@link br}\n */\n intersectsWithRect(tl: Point, br: Point): boolean {\n const intersection = Intersection.intersectPolygonRectangle(\n this.getCoords(),\n tl,\n br,\n );\n return intersection.status === 'Intersection';\n }\n\n /**\n * Checks if object intersects with another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object intersects with another object\n */\n intersectsWithObject(other: ObjectGeometry): boolean {\n const intersection = Intersection.intersectPolygonPolygon(\n this.getCoords(),\n other.getCoords(),\n );\n\n return (\n intersection.status === 'Intersection' ||\n intersection.status === 'Coincident' ||\n other.isContainedWithinObject(this) ||\n this.isContainedWithinObject(other)\n );\n }\n\n /**\n * Checks if object is fully contained within area of another object\n * @param {Object} other Object to test\n * @return {Boolean} true if object is fully contained within area of another object\n */\n isContainedWithinObject(other: ObjectGeometry): boolean {\n const points = this.getCoords();\n return points.every((point) => other.containsPoint(point));\n }\n\n /**\n * Checks if object is fully contained within the scene rect formed by {@link tl} and {@link br}\n */\n isContainedWithinRect(tl: Point, br: Point): boolean {\n const { left, top, width, height } = this.getBoundingRect();\n return (\n left >= tl.x &&\n left + width <= br.x &&\n top >= tl.y &&\n top + height <= br.y\n );\n }\n\n isOverlapping(other: T): boolean {\n return (\n this.intersectsWithObject(other) ||\n this.isContainedWithinObject(other) ||\n other.isContainedWithinObject(this)\n );\n }\n\n /**\n * Checks if point is inside the object\n * @param {Point} point Point to check against\n * @return {Boolean} true if point is inside the object\n */\n containsPoint(point: Point): boolean {\n return Intersection.isPointInPolygon(point, this.getCoords());\n }\n\n /**\n * Checks if object is contained within the canvas with current viewportTransform\n * the check is done stopping at first point that appears on screen\n * @return {Boolean} true if object is fully or partially contained within canvas\n */\n isOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n const points = this.getCoords();\n // if some point is on screen, the object is on screen.\n if (\n points.some(\n (point) =>\n point.x <= br.x &&\n point.x >= tl.x &&\n point.y <= br.y &&\n point.y >= tl.y,\n )\n ) {\n return true;\n }\n // no points on screen, check intersection with absolute coordinates\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n // check if the object is so big that it contains the entire viewport\n return this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Checks if object is partially contained within the canvas with current viewportTransform\n * @return {Boolean} true if object is partially contained within canvas\n */\n isPartiallyOnScreen(): boolean {\n if (!this.canvas) {\n return false;\n }\n const { tl, br } = this.canvas.vptCoords;\n if (this.intersectsWithRect(tl, br)) {\n return true;\n }\n const allPointsAreOutside = this.getCoords().every(\n (point) =>\n (point.x >= br.x || point.x <= tl.x) &&\n (point.y >= br.y || point.y <= tl.y),\n );\n // check if the object is so big that it contains the entire viewport\n return allPointsAreOutside && this.containsPoint(tl.midPointFrom(br));\n }\n\n /**\n * Returns coordinates of object's bounding rectangle (left, top, width, height)\n * the box is intended as aligned to axis of canvas.\n * @return {Object} Object with left, top, width, height properties\n */\n getBoundingRect(): TBBox {\n return makeBoundingBoxFromPoints(this.getCoords());\n }\n\n /**\n * Returns width of an object's bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} width value\n */\n getScaledWidth(): number {\n return this._getTransformedDimensions().x;\n }\n\n /**\n * Returns height of an object bounding box counting transformations\n * @todo shouldn't this account for group transform and return the actual size in canvas coordinate plane?\n * @return {Number} height value\n */\n getScaledHeight(): number {\n return this._getTransformedDimensions().y;\n }\n\n /**\n * Scales an object (equally by x and y)\n * @param {Number} value Scale factor\n * @return {void}\n */\n scale(value: number): void {\n this._set(SCALE_X, value);\n this._set(SCALE_Y, value);\n this.setCoords();\n }\n\n /**\n * Scales an object to a given width, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New width value\n * @return {void}\n */\n scaleToWidth(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().width / this.getScaledWidth();\n return this.scale(value / this.width / boundingRectFactor);\n }\n\n /**\n * Scales an object to a given height, with respect to bounding box (scaling by x/y equally)\n * @param {Number} value New height value\n * @return {void}\n */\n scaleToHeight(value: number) {\n // adjust to bounding rect factor so that rotated shapes would fit as well\n const boundingRectFactor =\n this.getBoundingRect().height / this.getScaledHeight();\n return this.scale(value / this.height / boundingRectFactor);\n }\n\n getCanvasRetinaScaling() {\n return this.canvas?.getRetinaScaling() || 1;\n }\n\n /**\n * Returns the object angle relative to canvas counting also the group property\n * @returns {TDegree}\n */\n getTotalAngle(): TDegree {\n return this.group\n ? radiansToDegrees(calcPlaneRotation(this.calcTransformMatrix()))\n : this.angle;\n }\n\n /**\n * Retrieves viewportTransform from Object's canvas if available\n * @return {TMat2D}\n */\n getViewportTransform(): TMat2D {\n return this.canvas?.viewportTransform || (iMatrix.concat() as TMat2D);\n }\n\n /**\n * Calculates the coordinates of the 4 corner of the bbox, in absolute coordinates.\n * those never change with zoom or viewport changes.\n * @return {TCornerPoint}\n */\n calcACoords(): TCornerPoint {\n const rotateMatrix = createRotateMatrix({ angle: this.angle }),\n { x, y } = this.getRelativeCenterPoint(),\n tMatrix = createTranslateMatrix(x, y),\n finalMatrix = multiplyTransformMatrices(tMatrix, rotateMatrix),\n dim = this._getTransformedDimensions(),\n w = dim.x / 2,\n h = dim.y / 2;\n return {\n // corners\n tl: transformPoint({ x: -w, y: -h }, finalMatrix),\n tr: transformPoint({ x: w, y: -h }, finalMatrix),\n bl: transformPoint({ x: -w, y: h }, finalMatrix),\n br: transformPoint({ x: w, y: h }, finalMatrix),\n };\n }\n\n /**\n * Sets corner and controls position coordinates based on current angle, width and height, left and top.\n * aCoords are used to quickly find an object on the canvas.\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n */\n setCoords(): void {\n this.aCoords = this.calcACoords();\n }\n\n transformMatrixKey(skipGroup = false): number[] {\n let prefix: number[] = [];\n if (!skipGroup && this.group) {\n prefix = this.group.transformMatrixKey(skipGroup);\n }\n prefix.push(\n this.top,\n this.left,\n this.width,\n this.height,\n this.scaleX,\n this.scaleY,\n this.angle,\n this.strokeWidth,\n this.skewX,\n this.skewY,\n +this.flipX,\n +this.flipY,\n resolveOrigin(this.originX),\n resolveOrigin(this.originY),\n );\n\n return prefix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties.\n * @param {Boolean} [skipGroup] return transform matrix for object not counting parent transformations\n * There are some situation in which this is useful to avoid the fake rotation.\n * @return {TMat2D} transform matrix for the object\n */\n calcTransformMatrix(skipGroup = false): TMat2D {\n let matrix = this.calcOwnMatrix();\n if (skipGroup || !this.group) {\n return matrix;\n }\n const key = this.transformMatrixKey(skipGroup),\n cache = this.matrixCache;\n if (cache && cache.key.every((x, i) => x === key[i])) {\n return cache.value;\n }\n if (this.group) {\n matrix = multiplyTransformMatrices(\n this.group.calcTransformMatrix(false),\n matrix,\n );\n }\n this.matrixCache = {\n key,\n value: matrix,\n };\n return matrix;\n }\n\n /**\n * calculate transform matrix that represents the current transformations from the\n * object's properties, this matrix does not include the group transformation\n * @return {TMat2D} transform matrix for the object\n */\n calcOwnMatrix(): TMat2D {\n const key = this.transformMatrixKey(true),\n cache = this.ownMatrixCache;\n if (cache && cache.key === key) {\n return cache.value;\n }\n const center = this.getRelativeCenterPoint(),\n options = {\n angle: this.angle,\n translateX: center.x,\n translateY: center.y,\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n flipX: this.flipX,\n flipY: this.flipY,\n },\n value = composeMatrix(options);\n this.ownMatrixCache = {\n key,\n value,\n };\n return value;\n }\n\n /**\n * Calculate object dimensions from its properties\n * @private\n * @returns {Point} dimensions\n */\n _getNonTransformedDimensions(): Point {\n return new Point(this.width, this.height).scalarAdd(this.strokeWidth);\n }\n\n /**\n * Calculate object dimensions for controls box, including padding and canvas zoom.\n * and active selection\n * @private\n * @param {object} [options] transform options\n * @returns {Point} dimensions\n */\n _calculateCurrentDimensions(options?: any): Point {\n return this._getTransformedDimensions(options)\n .transform(this.getViewportTransform(), true)\n .scalarAdd(2 * this.padding);\n }\n\n // #region Origin\n\n declare top: number;\n declare left: number;\n declare width: number;\n declare height: number;\n declare flipX: boolean;\n declare flipY: boolean;\n declare scaleX: number;\n declare scaleY: number;\n declare skewX: number;\n declare skewY: number;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originX: TOriginX;\n /**\n * @deprecated please use 'center' as value in new projects\n * */\n declare originY: TOriginY;\n declare angle: TDegree;\n declare strokeWidth: number;\n declare strokeUniform: boolean;\n\n /**\n * Object containing this object.\n * can influence its size and position\n */\n declare group?: Group;\n\n /**\n * Calculate object bounding box dimensions from its properties scale, skew.\n * This bounding box is aligned with object angle and not with canvas axis or screen.\n * @param {Object} [options]\n * @param {Number} [options.scaleX]\n * @param {Number} [options.scaleY]\n * @param {Number} [options.skewX]\n * @param {Number} [options.skewY]\n * @private\n * @returns {Point} dimensions\n */\n _getTransformedDimensions(options: any = {}): Point {\n const dimOptions = {\n // if scaleX or scaleY are negative numbers,\n // this will return dimensions that are negative.\n // and this will break assumptions around the codebase\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n width: this.width,\n height: this.height,\n strokeWidth: this.strokeWidth,\n ...options,\n };\n // stroke is applied before/after transformations are applied according to `strokeUniform`\n const strokeWidth = dimOptions.strokeWidth;\n let preScalingStrokeValue = strokeWidth,\n postScalingStrokeValue = 0;\n\n if (this.strokeUniform) {\n preScalingStrokeValue = 0;\n postScalingStrokeValue = strokeWidth;\n }\n const dimX = dimOptions.width + preScalingStrokeValue,\n dimY = dimOptions.height + preScalingStrokeValue,\n noSkew = dimOptions.skewX === 0 && dimOptions.skewY === 0;\n let finalDimensions;\n if (noSkew) {\n finalDimensions = new Point(\n dimX * dimOptions.scaleX,\n dimY * dimOptions.scaleY,\n );\n } else {\n finalDimensions = sizeAfterTransform(\n dimX,\n dimY,\n calcDimensionsMatrix(dimOptions),\n );\n }\n\n return finalDimensions.scalarAdd(postScalingStrokeValue);\n }\n\n /**\n * Translates the coordinates from a set of origin to another (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} fromOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} fromOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @param {TOriginX} toOriginX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} toOriginY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToGivenOrigin(\n point: Point,\n fromOriginX: TOriginX,\n fromOriginY: TOriginY,\n toOriginX: TOriginX,\n toOriginY: TOriginY,\n ): Point {\n let x = point.x,\n y = point.y;\n const offsetX = resolveOrigin(toOriginX) - resolveOrigin(fromOriginX),\n offsetY = resolveOrigin(toOriginY) - resolveOrigin(fromOriginY);\n\n if (offsetX || offsetY) {\n const dim = this._getTransformedDimensions();\n x += offsetX * dim.x;\n y += offsetY * dim.y;\n }\n\n return new Point(x, y);\n }\n\n /**\n * Translates the coordinates from origin to center coordinates (based on the object's dimensions)\n * @param {Point} point The point which corresponds to the originX and originY params\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToCenterPoint(\n point: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n if (originX === CENTER && originY === CENTER) {\n return point;\n }\n const p = this.translateToGivenOrigin(\n point,\n originX,\n originY,\n CENTER,\n CENTER,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), point);\n }\n return p;\n }\n\n /**\n * Translates the coordinates from center to origin coordinates (based on the object's dimensions)\n * @param {Point} center The point which corresponds to center of the object\n * @param {OriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {OriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n translateToOriginPoint(\n center: Point,\n originX: TOriginX,\n originY: TOriginY,\n ): Point {\n const p = this.translateToGivenOrigin(\n center,\n CENTER,\n CENTER,\n originX,\n originY,\n );\n if (this.angle) {\n return p.rotate(degreesToRadians(this.angle), center);\n }\n return p;\n }\n\n /**\n * Returns the center coordinates of the object relative to canvas\n * @return {Point}\n */\n getCenterPoint(): Point {\n const relCenter = this.getRelativeCenterPoint();\n return this.group\n ? transformPoint(relCenter, this.group.calcTransformMatrix())\n : relCenter;\n }\n\n /**\n * Returns the center coordinates of the object relative to it's parent\n * @return {Point}\n */\n getRelativeCenterPoint(): Point {\n return this.translateToCenterPoint(\n new Point(this.left, this.top),\n this.originX,\n this.originY,\n );\n }\n\n /**\n * Returns the position of the object as if it has a different origin.\n * Take an object that has left, top set to 100, 100 with origin 'left', 'top'.\n * Return the values of left top ( wrapped in a point ) that you would need to keep\n * the same position if origin where different.\n * Alternatively you can use this to also find which point in the parent plane is a specific origin\n * ( where is the bottom right corner of my object? )\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {Point}\n */\n getPointByOrigin(originX: TOriginX, originY: TOriginY): Point {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n }\n\n /**\n * Sets the position of the object taking into consideration the object's origin\n * @param {Point} pos The new position of the object\n * @param {TOriginX} originX Horizontal origin: 'left', 'center' or 'right'\n * @param {TOriginY} originY Vertical origin: 'top', 'center' or 'bottom'\n * @return {void}\n */\n setPositionByOrigin(pos: Point, originX: TOriginX, originY: TOriginY) {\n const center = this.translateToCenterPoint(pos, originX, originY),\n position = this.translateToOriginPoint(\n center,\n this.originX,\n this.originY,\n );\n this.set({ left: position.x, top: position.y });\n }\n\n /**\n * @private\n */\n _getLeftTopCoords() {\n return this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n LEFT,\n TOP,\n );\n }\n}\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport {\n ALIASING_LIMIT,\n CENTER,\n iMatrix,\n LEFT,\n SCALE_X,\n SCALE_Y,\n STROKE,\n FILL,\n TOP,\n VERSION,\n} from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport { Shadow } from '../../Shadow';\nimport type {\n TDegree,\n TFiller,\n TSize,\n TCacheCanvasDimensions,\n Abortable,\n TOptions,\n ImageFormat,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { runningAnimations } from '../../util/animation/AnimationRegistry';\nimport { capValue } from '../../util/misc/capValue';\nimport {\n createCanvasElement,\n createCanvasElementFor,\n toDataURL,\n} from '../../util/misc/dom';\nimport { invertTransform, qrDecompose } from '../../util/misc/matrix';\nimport { enlivenObjectEnlivables } from '../../util/misc/objectEnlive';\nimport {\n resetObjectTransform,\n saveObjectTransform,\n} from '../../util/misc/objectTransforms';\nimport { sendObjectToPlane } from '../../util/misc/planeChange';\nimport { pick, pickBy } from '../../util/misc/pick';\nimport { toFixed } from '../../util/misc/toFixed';\nimport type { Group } from '../Group';\nimport { StaticCanvas } from '../../canvas/StaticCanvas';\nimport { isFiller, isSerializableFiller } from '../../util/typeAssertions';\nimport type { FabricImage } from '../Image';\nimport {\n cacheProperties,\n fabricObjectDefaultValues,\n stateProperties,\n} from './defaultValues';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { SerializedObjectProps } from './types/SerializedObjectProps';\nimport type { ObjectProps } from './types/ObjectProps';\nimport { getDevicePixelRatio, getEnv } from '../../env';\nimport { log } from '../../util/internals/console';\nimport type { TColorArg } from '../../color/typedefs';\nimport type { TAnimation } from '../../util/animation/animate';\nimport { animate, animateColor } from '../../util/animation/animate';\nimport type {\n AnimationOptions,\n ArrayAnimationOptions,\n ColorAnimationOptions,\n ValueAnimationOptions,\n} from '../../util/animation/types';\nimport { ObjectGeometry } from './ObjectGeometry';\n\ntype TAncestor = FabricObject;\ntype TCollection = Group;\n\nexport type Ancestors =\n | [FabricObject | Group]\n | [FabricObject | Group, ...Group[]]\n | Group[];\n\nexport type AncestryComparison = {\n /**\n * common ancestors of `this` and`other`(may include`this` | `other`)\n */\n common: Ancestors;\n /**\n * ancestors that are of `this` only\n */\n fork: Ancestors;\n /**\n * ancestors that are of `other` only\n */\n otherFork: Ancestors;\n};\n\nexport type TCachedFabricObject = T &\n Required<\n Pick<\n T,\n | 'zoomX'\n | 'zoomY'\n | '_cacheCanvas'\n | '_cacheContext'\n | 'cacheTranslationX'\n | 'cacheTranslationY'\n >\n > & {\n _cacheContext: CanvasRenderingContext2D;\n };\n\nexport type ObjectToCanvasElementOptions = {\n format?: ImageFormat;\n /** Multiplier to scale by */\n multiplier?: number;\n /** Cropping left offset. Introduced in v1.2.14 */\n left?: number;\n /** Cropping top offset. Introduced in v1.2.14 */\n top?: number;\n /** Cropping width. Introduced in v1.2.14 */\n width?: number;\n /** Cropping height. Introduced in v1.2.14 */\n height?: number;\n /** Enable retina scaling for clone image. Introduce in 1.6.4 */\n enableRetinaScaling?: boolean;\n /** Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4 */\n withoutTransform?: boolean;\n /** Remove current object shadow. Introduced in 2.4.2 */\n withoutShadow?: boolean;\n /** Account for canvas viewport transform */\n viewportTransform?: boolean;\n /** Function to create the output canvas to export onto */\n canvasProvider?: (el?: HTMLCanvasElement) => T;\n};\n\ntype toDataURLOptions = ObjectToCanvasElementOptions & {\n quality?: number;\n};\n\nexport type DrawContext =\n | {\n parentClipPaths: FabricObject[];\n width: number;\n height: number;\n cacheTranslationX: number;\n cacheTranslationY: number;\n zoomX: number;\n zoomY: number;\n }\n | Record;\n\n/**\n * Root object class from which all 2d shape classes inherit from\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#objects}\n *\n * @fires added\n * @fires removed\n *\n * @fires selected\n * @fires deselected\n *\n * @fires rotating\n * @fires scaling\n * @fires moving\n * @fires skewing\n * @fires modified\n *\n * @fires mousedown\n * @fires mouseup\n * @fires mouseover\n * @fires mouseout\n * @fires mousewheel\n * @fires mousedblclick\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drop\n */\nexport class FabricObject<\n Props extends TOptions = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends ObjectGeometry\n implements ObjectProps\n{\n declare minScaleLimit: number;\n\n declare opacity: number;\n\n declare paintFirst: 'fill' | 'stroke';\n declare fill: string | TFiller | null;\n declare fillRule: CanvasFillRule;\n declare stroke: string | TFiller | null;\n declare strokeDashArray: number[] | null;\n declare strokeDashOffset: number;\n declare strokeLineCap: CanvasLineCap;\n declare strokeLineJoin: CanvasLineJoin;\n declare strokeMiterLimit: number;\n\n declare globalCompositeOperation: GlobalCompositeOperation;\n declare backgroundColor: string;\n\n declare shadow: Shadow | null;\n\n declare visible: boolean;\n\n declare includeDefaultValues: boolean;\n declare excludeFromExport: boolean;\n\n declare objectCaching: boolean;\n\n declare clipPath?: FabricObject;\n declare inverted: boolean;\n declare absolutePositioned: boolean;\n declare centeredRotation: boolean;\n declare centeredScaling: boolean;\n\n /**\n * This list of properties is used to check if the state of an object is changed.\n * This state change now is only used for children of groups to understand if a group\n * needs its cache regenerated during a .set call\n * @type Array\n */\n static stateProperties: string[] = stateProperties;\n\n /**\n * List of properties to consider when checking if cache needs refresh\n * Those properties are checked by\n * calls to Object.set(key, value). If the key is in this list, the object is marked as dirty\n * and refreshed at the next render\n * @type Array\n */\n static cacheProperties: string[] = cacheProperties;\n\n /**\n * When set to `true`, object's cache will be rerendered next render call.\n * since 1.7.0\n * @type Boolean\n * @default true\n */\n declare dirty: boolean;\n\n /**\n * Quick access for the _cacheCanvas rendering context\n * This is part of the objectCaching feature\n * since 1.7.0\n * @type boolean\n * @default undefined\n * @private\n */\n _cacheContext: CanvasRenderingContext2D | null = null;\n\n /**\n * A reference to the HTMLCanvasElement that is used to contain the cache of the object\n * this canvas element is resized and cleared as needed\n * Is marked private, you can read it, don't use it since it is handled by fabric\n * since 1.7.0\n * @type HTMLCanvasElement\n * @default undefined\n * @private\n */\n declare _cacheCanvas?: HTMLCanvasElement;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, X axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomX?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare zoomY?: number;\n\n /**\n * zoom level used on the cacheCanvas to draw the cache, Y axe\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationX?: number;\n\n /**\n * translation of the cacheCanvas away from the center, for subpixel accuracy and crispness\n * since 1.7.0\n * @type number\n * @default undefined\n * @private\n */\n declare cacheTranslationY?: number;\n\n /**\n * A reference to the parent of the object, usually a Group\n * @type number\n * @default undefined\n * @private\n */\n declare group?: Group;\n\n /**\n * Indicate if the object is sitting on a cache dedicated to it\n * or is part of a larger cache for many object ( a group for example)\n * @type number\n * @default undefined\n * @private\n */\n declare ownCaching?: boolean;\n\n /**\n * Private. indicates if the object inside a group is on a transformed context or not\n * or is part of a larger cache for many object ( a group for example)\n * @type boolean\n * @default undefined\n * @private\n */\n declare _transformDone?: boolean;\n\n static ownDefaults = fabricObjectDefaultValues;\n\n static getDefaults(): Record {\n return FabricObject.ownDefaults;\n }\n\n /**\n * The class type.\n * This is used for serialization and deserialization purposes and internally it can be used\n * to identify classes.\n * When we transform a class in a plain JS object we need a way to recognize which class it was,\n * and the type is the way we do that. It has no other purposes and you should not give one.\n * Hard to reach on instances and please do not use to drive instance's logic (this.constructor.type).\n * To idenfity a class use instanceof class ( instanceof Rect ).\n * We do not do that in fabricJS code because we want to try to have code splitting possible.\n */\n static type = 'FabricObject';\n\n /**\n * Legacy identifier of the class. Prefer using utils like isType or instanceOf\n * Will be removed in fabric 7 or 8.\n * The setter exists to avoid type errors in old code and possibly current deserialization code.\n * DO NOT build new code around this type value\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n const name = (this.constructor as typeof FabricObject).type;\n if (name === 'FabricObject') {\n return 'object';\n }\n return name.toLowerCase();\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, FabricObject.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * Create a the canvas used to keep the cached copy of the object\n * @private\n */\n _createCacheCanvas() {\n this._cacheCanvas = createCanvasElement();\n this._cacheContext = this._cacheCanvas.getContext('2d');\n this._updateCacheCanvas();\n // if canvas gets created, is empty, so dirty.\n this.dirty = true;\n }\n\n /**\n * Limit the cache dimensions so that X * Y do not cross config.perfLimitSizeTotal\n * and each side do not cross fabric.cacheSideLimit\n * those numbers are configurable so that you can get as much detail as you want\n * making bargain with performances.\n * @param {Object} dims\n * @param {Object} dims.width width of canvas\n * @param {Object} dims.height height of canvas\n * @param {Object} dims.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @param {Object} dims.zoomY zoomY zoom value to unscale the canvas before drawing cache\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _limitCacheSize(\n dims: TSize & { zoomX: number; zoomY: number; capped: boolean } & any,\n ) {\n const width = dims.width,\n height = dims.height,\n max = config.maxCacheSideLimit,\n min = config.minCacheSideLimit;\n if (\n width <= max &&\n height <= max &&\n width * height <= config.perfLimitSizeTotal\n ) {\n if (width < min) {\n dims.width = min;\n }\n if (height < min) {\n dims.height = min;\n }\n return dims;\n }\n const ar = width / height,\n [limX, limY] = cache.limitDimsByArea(ar),\n x = capValue(min, limX, max),\n y = capValue(min, limY, max);\n if (width > x) {\n dims.zoomX /= width / x;\n dims.width = x;\n dims.capped = true;\n }\n if (height > y) {\n dims.zoomY /= height / y;\n dims.height = y;\n dims.capped = true;\n }\n return dims;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @return {Object}.x width of object to be cached\n * @return {Object}.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const objectScale = this.getTotalObjectScaling(),\n // calculate dimensions without skewing\n dim = this._getTransformedDimensions({ skewX: 0, skewY: 0 }),\n neededX = (dim.x * objectScale.x) / this.scaleX,\n neededY = (dim.y * objectScale.y) / this.scaleY;\n return {\n // for sure this ALIASING_LIMIT is slightly creating problem\n // in situation in which the cache canvas gets an upper limit\n // also objectScale contains already scaleX and scaleY\n width: Math.ceil(neededX + ALIASING_LIMIT),\n height: Math.ceil(neededY + ALIASING_LIMIT),\n zoomX: objectScale.x,\n zoomY: objectScale.y,\n x: neededX,\n y: neededY,\n };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const canvas = this._cacheCanvas!,\n context = this._cacheContext,\n { width, height, zoomX, zoomY, x, y } = this._limitCacheSize(\n this._getCacheCanvasDimensions(),\n ),\n dimensionsChanged = width !== canvas.width || height !== canvas.height,\n zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY;\n\n if (!canvas || !context) {\n return false;\n }\n\n const shouldRedraw = dimensionsChanged || zoomChanged;\n\n if (shouldRedraw) {\n if (width !== canvas.width || height !== canvas.height) {\n canvas.width = width;\n canvas.height = height;\n } else {\n context.setTransform(1, 0, 0, 1, 0, 0);\n context.clearRect(0, 0, canvas.width, canvas.height);\n }\n const drawingWidth = x / 2;\n const drawingHeight = y / 2;\n this.cacheTranslationX =\n Math.round(canvas.width / 2 - drawingWidth) + drawingWidth;\n this.cacheTranslationY =\n Math.round(canvas.height / 2 - drawingHeight) + drawingHeight;\n context.translate(this.cacheTranslationX, this.cacheTranslationY);\n context.scale(zoomX, zoomY);\n this.zoomX = zoomX;\n this.zoomY = zoomY;\n return true;\n }\n return false;\n }\n\n /**\n * Sets object's properties from options, for class constructor only.\n * Needs to be overridden for different defaults.\n * @protected\n * @param {Object} [options] Options object\n */\n protected setOptions(options: Record = {}) {\n this._setOptions(options);\n }\n\n /**\n * Transforms context when rendering an object\n * @param {CanvasRenderingContext2D} ctx Context\n */\n transform(ctx: CanvasRenderingContext2D) {\n const needFullTransform =\n (this.group && !this.group._transformDone) ||\n (this.group && this.canvas && ctx === (this.canvas as Canvas).contextTop);\n const m = this.calcTransformMatrix(!needFullTransform);\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n\n /**\n * Return the object scale factor counting also the group scaling\n * @return {Point}\n */\n getObjectScaling() {\n // if the object is a top level one, on the canvas, we go for simple aritmetic\n // otherwise the complex method with angles will return approximations and decimals\n // and will likely kill the cache when not needed\n // https://github.com/fabricjs/fabric.js/issues/7157\n if (!this.group) {\n return new Point(Math.abs(this.scaleX), Math.abs(this.scaleY));\n }\n // if we are inside a group total zoom calculation is complex, we defer to generic matrices\n const options = qrDecompose(this.calcTransformMatrix());\n return new Point(Math.abs(options.scaleX), Math.abs(options.scaleY));\n }\n\n /**\n * Return the object scale factor counting also the group scaling, zoom and retina\n * @return {Object} object with scaleX and scaleY properties\n */\n getTotalObjectScaling() {\n const scale = this.getObjectScaling();\n if (this.canvas) {\n const zoom = this.canvas.getZoom();\n const retina = this.getCanvasRetinaScaling();\n return scale.scalarMultiply(zoom * retina);\n }\n return scale;\n }\n\n /**\n * Return the object opacity counting also the group property\n * @return {Number}\n */\n getObjectOpacity() {\n let opacity = this.opacity;\n if (this.group) {\n opacity *= this.group.getObjectOpacity();\n }\n return opacity;\n }\n\n /**\n * Makes sure the scale is valid and modifies it if necessary\n * @todo: this is a control action issue, not a geometry one\n * @private\n * @param {Number} value, unconstrained\n * @return {Number} constrained value;\n */\n _constrainScale(value: number): number {\n if (Math.abs(value) < this.minScaleLimit) {\n if (value < 0) {\n return -this.minScaleLimit;\n } else {\n return this.minScaleLimit;\n }\n } else if (value === 0) {\n return 0.0001;\n }\n return value;\n }\n\n /**\n * Handles setting values on the instance and handling internal side effects\n * @protected\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (key === SCALE_X || key === SCALE_Y) {\n value = this._constrainScale(value);\n }\n if (key === SCALE_X && value < 0) {\n this.flipX = !this.flipX;\n value *= -1;\n } else if (key === 'scaleY' && value < 0) {\n this.flipY = !this.flipY;\n value *= -1;\n // i don't like this automatic initialization here\n } else if (key === 'shadow' && value && !(value instanceof Shadow)) {\n value = new Shadow(value);\n }\n\n const isChanged = this[key as keyof this] !== value;\n this[key as keyof this] = value;\n\n // invalidate caches\n if (\n isChanged &&\n (this.constructor as typeof FabricObject).cacheProperties.includes(key)\n ) {\n this.dirty = true;\n }\n // a dirty child makes the parent dirty.\n // but a non dirty child does not make the parent not dirty.\n // the parent could be dirty for some other reason.\n this.parent &&\n (this.dirty ||\n (isChanged &&\n (this.constructor as typeof FabricObject).stateProperties.includes(\n key,\n ))) &&\n this.parent._set('dirty', true);\n\n return this;\n }\n\n /*\n * @private\n * return if the object would be visible in rendering\n * @memberOf FabricObject.prototype\n * @return {Boolean}\n */\n isNotVisible() {\n return (\n this.opacity === 0 ||\n (!this.width && !this.height && this.strokeWidth === 0) ||\n !this.visible\n );\n }\n\n /**\n * Renders an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n // do not render if width/height are zeros or object is not visible\n if (this.isNotVisible()) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n ctx.save();\n this._setupCompositeOperation(ctx);\n this.drawSelectionBackground(ctx);\n this.transform(ctx);\n this._setOpacity(ctx);\n this._setShadow(ctx);\n if (this.shouldCache()) {\n (this as TCachedFabricObject).renderCache();\n (this as TCachedFabricObject).drawCacheOnCanvas(ctx);\n } else {\n this._removeCacheCanvas();\n this.drawObject(ctx, false, {});\n this.dirty = false;\n }\n ctx.restore();\n }\n\n drawSelectionBackground(_ctx: CanvasRenderingContext2D) {\n /* no op */\n }\n\n renderCache(this: TCachedFabricObject, options?: any) {\n options = options || {};\n if (!this._cacheCanvas || !this._cacheContext) {\n this._createCacheCanvas();\n }\n if (this.isCacheDirty() && this._cacheContext) {\n const { zoomX, zoomY, cacheTranslationX, cacheTranslationY } = this;\n const { width, height } = this._cacheCanvas;\n this.drawObject(this._cacheContext, options.forClipping, {\n zoomX,\n zoomY,\n cacheTranslationX,\n cacheTranslationY,\n width,\n height,\n parentClipPaths: [],\n });\n this.dirty = false;\n }\n }\n\n /**\n * Remove cacheCanvas and its dimensions from the objects\n */\n _removeCacheCanvas() {\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n /**\n * return true if the object will draw a stroke\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when stroke happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the stroke is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasStroke() {\n return (\n this.stroke && this.stroke !== 'transparent' && this.strokeWidth !== 0\n );\n }\n\n /**\n * return true if the object will draw a fill\n * Does not consider text styles. This is just a shortcut used at rendering time\n * We want it to be an approximation and be fast.\n * wrote to avoid extra caching, it has to return true when fill happens,\n * can guess when it will not happen at 100% chance, does not matter if it misses\n * some use case where the fill is invisible.\n * @since 3.0.0\n * @returns Boolean\n */\n hasFill() {\n return this.fill && this.fill !== 'transparent';\n }\n\n /**\n * When set to `true`, force the object to have its own cache, even if it is inside a group\n * it may be needed when your object behave in a particular way on the cache and always needs\n * its own isolated canvas to render correctly.\n * Created to be overridden\n * since 1.7.12\n * @returns Boolean\n */\n needsItsOwnCache() {\n if (\n this.paintFirst === STROKE &&\n this.hasFill() &&\n this.hasStroke() &&\n !!this.shadow\n ) {\n return true;\n }\n if (this.clipPath) {\n return true;\n }\n return false;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * Read as: cache if is needed, or if the feature is enabled but we are not already caching.\n * @return {Boolean}\n */\n shouldCache() {\n this.ownCaching =\n this.needsItsOwnCache() ||\n (this.objectCaching && (!this.parent || !this.parent.isOnACache()));\n return this.ownCaching;\n }\n\n /**\n * Check if this object will cast a shadow with an offset.\n * used by Group.shouldCache to know if child has a shadow recursively\n * @return {Boolean}\n * @deprecated\n */\n willDrawShadow() {\n return (\n !!this.shadow && (this.shadow.offsetX !== 0 || this.shadow.offsetY !== 0)\n );\n }\n\n /**\n * Execute the drawing operation for an object clipPath\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {FabricObject} clipPath\n */\n drawClipPathOnCache(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject,\n canvasWithClipPath: HTMLCanvasElement,\n ) {\n ctx.save();\n // DEBUG: uncomment this line, comment the following\n // ctx.globalAlpha = 0.4\n if (clipPath.inverted) {\n ctx.globalCompositeOperation = 'destination-out';\n } else {\n ctx.globalCompositeOperation = 'destination-in';\n }\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n //ctx.scale(1 / 2, 1 / 2);\n ctx.drawImage(canvasWithClipPath, 0, 0);\n ctx.restore();\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {boolean} forClipping apply clipping styles\n * @param {DrawContext} context additional context for rendering\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n const originalFill = this.fill,\n originalStroke = this.stroke;\n if (forClipping) {\n this.fill = 'black';\n this.stroke = '';\n this._setClippingProperties(ctx);\n } else {\n this._renderBackground(ctx);\n }\n this._render(ctx);\n this._drawClipPath(ctx, this.clipPath, context);\n this.fill = originalFill;\n this.stroke = originalStroke;\n }\n\n private createClipPathLayer(\n this: TCachedFabricObject,\n clipPath: FabricObject,\n context: DrawContext,\n ) {\n const canvas = createCanvasElementFor(context as TSize);\n const ctx = canvas.getContext('2d')!;\n ctx.translate(context.cacheTranslationX, context.cacheTranslationY);\n ctx.scale(context.zoomX, context.zoomY);\n clipPath._cacheCanvas = canvas;\n context.parentClipPaths.forEach((prevClipPath) => {\n prevClipPath.transform(ctx);\n });\n context.parentClipPaths.push(clipPath);\n if (clipPath.absolutePositioned) {\n const m = invertTransform(this.calcTransformMatrix());\n ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);\n }\n clipPath.transform(ctx);\n clipPath.drawObject(ctx, true, context);\n return canvas;\n }\n\n /**\n * Prepare clipPath state and cache and draw it on instance's cache\n * @param {CanvasRenderingContext2D} ctx\n * @param {FabricObject} clipPath\n */\n _drawClipPath(\n ctx: CanvasRenderingContext2D,\n clipPath: FabricObject | undefined,\n context: DrawContext,\n ) {\n if (!clipPath) {\n return;\n }\n // needed to setup _transformDone\n // TODO find a better solution?\n clipPath._transformDone = true;\n const canvas = (this as TCachedFabricObject).createClipPathLayer(\n clipPath,\n context,\n );\n this.drawClipPathOnCache(ctx, clipPath, canvas);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(this: TCachedFabricObject, ctx: CanvasRenderingContext2D) {\n ctx.scale(1 / this.zoomX, 1 / this.zoomY);\n ctx.drawImage(\n this._cacheCanvas,\n -this.cacheTranslationX,\n -this.cacheTranslationY,\n );\n }\n\n /**\n * Check if cache is dirty\n * @param {Boolean} skipCanvas skip canvas checks because this object is painted\n * on parent canvas.\n */\n isCacheDirty(skipCanvas = false) {\n if (this.isNotVisible()) {\n return false;\n }\n const canvas = this._cacheCanvas;\n const ctx = this._cacheContext;\n if (canvas && ctx && !skipCanvas && this._updateCacheCanvas()) {\n // in this case the context is already cleared.\n return true;\n } else {\n if (this.dirty || (this.clipPath && this.clipPath.absolutePositioned)) {\n if (canvas && ctx && !skipCanvas) {\n ctx.save();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Draws a background for the object big as its untransformed dimensions\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderBackground(ctx: CanvasRenderingContext2D) {\n if (!this.backgroundColor) {\n return;\n }\n const dim = this._getNonTransformedDimensions();\n ctx.fillStyle = this.backgroundColor;\n\n ctx.fillRect(-dim.x / 2, -dim.y / 2, dim.x, dim.y);\n // if there is background color no other shadows\n // should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setOpacity(ctx: CanvasRenderingContext2D) {\n if (this.group && !this.group._transformDone) {\n ctx.globalAlpha = this.getObjectOpacity();\n } else {\n ctx.globalAlpha *= this.opacity;\n }\n }\n\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n decl: Pick<\n this,\n | 'stroke'\n | 'strokeWidth'\n | 'strokeLineCap'\n | 'strokeDashOffset'\n | 'strokeLineJoin'\n | 'strokeMiterLimit'\n >,\n ) {\n const stroke = decl.stroke;\n if (stroke) {\n ctx.lineWidth = decl.strokeWidth;\n ctx.lineCap = decl.strokeLineCap;\n ctx.lineDashOffset = decl.strokeDashOffset;\n ctx.lineJoin = decl.strokeLineJoin;\n ctx.miterLimit = decl.strokeMiterLimit;\n if (isFiller(stroke)) {\n if (\n (stroke as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (stroke as Gradient<'linear'>).gradientTransform ||\n (stroke as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n this._applyPatternForTransformedGradient(ctx, stroke);\n } else {\n // is a simple gradient or pattern\n ctx.strokeStyle = stroke.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, stroke);\n }\n } else {\n // is a color\n ctx.strokeStyle = decl.stroke as string;\n }\n }\n }\n\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n if (fill) {\n if (isFiller(fill)) {\n ctx.fillStyle = fill.toLive(ctx)!;\n this._applyPatternGradientTransform(ctx, fill);\n } else {\n ctx.fillStyle = fill;\n }\n }\n }\n\n _setClippingProperties(ctx: CanvasRenderingContext2D) {\n ctx.globalAlpha = 1;\n ctx.strokeStyle = 'transparent';\n ctx.fillStyle = '#000000';\n }\n\n /**\n * @private\n * Sets line dash\n * @param {CanvasRenderingContext2D} ctx Context to set the dash line on\n * @param {Array} dashArray array representing dashes\n */\n _setLineDash(ctx: CanvasRenderingContext2D, dashArray?: number[] | null) {\n if (!dashArray || dashArray.length === 0) {\n return;\n }\n ctx.setLineDash(dashArray);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _setShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n const shadow = this.shadow,\n canvas = this.canvas,\n retinaScaling = this.getCanvasRetinaScaling(),\n [sx, , , sy] = canvas?.viewportTransform || iMatrix,\n multX = sx * retinaScaling,\n multY = sy * retinaScaling,\n scaling = shadow.nonScaling ? new Point(1, 1) : this.getObjectScaling();\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur =\n (shadow.blur *\n config.browserShadowBlurConstant *\n (multX + multY) *\n (scaling.x + scaling.y)) /\n 4;\n ctx.shadowOffsetX = shadow.offsetX * multX * scaling.x;\n ctx.shadowOffsetY = shadow.offsetY * multY * scaling.y;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _removeShadow(ctx: CanvasRenderingContext2D) {\n if (!this.shadow) {\n return;\n }\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TFiller} filler {@link Pattern} or {@link Gradient}\n */\n _applyPatternGradientTransform(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n if (!isFiller(filler)) {\n return { offsetX: 0, offsetY: 0 };\n }\n const t =\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform;\n const offsetX = -this.width / 2 + filler.offsetX || 0,\n offsetY = -this.height / 2 + filler.offsetY || 0;\n\n if ((filler as Gradient<'linear'>).gradientUnits === 'percentage') {\n ctx.transform(this.width, 0, 0, this.height, offsetX, offsetY);\n } else {\n ctx.transform(1, 0, 0, 1, offsetX, offsetY);\n }\n if (t) {\n ctx.transform(t[0], t[1], t[2], t[3], t[4], t[5]);\n }\n return { offsetX: offsetX, offsetY: offsetY };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderPaintInOrder(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderStroke(ctx);\n this._renderFill(ctx);\n } else {\n this._renderFill(ctx);\n this._renderStroke(ctx);\n }\n }\n\n /**\n * @private\n * function that actually render something on the context.\n * empty here to allow Obects to work on tests to benchmark fabric functionalites\n * not related to rendering\n * @param {CanvasRenderingContext2D} _ctx Context to render on\n */\n _render(_ctx: CanvasRenderingContext2D) {\n // placeholder to be overridden\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill) {\n return;\n }\n\n ctx.save();\n this._setFillStyles(ctx, this);\n if (this.fillRule === 'evenodd') {\n ctx.fill('evenodd');\n } else {\n ctx.fill();\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderStroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n if (this.strokeUniform) {\n const scaling = this.getObjectScaling();\n ctx.scale(1 / scaling.x, 1 / scaling.y);\n }\n this._setLineDash(ctx, this.strokeDashArray);\n this._setStrokeStyles(ctx, this);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Gradient} filler\n */\n _applyPatternForTransformedGradient(\n ctx: CanvasRenderingContext2D,\n filler: TFiller,\n ) {\n const dims = this._limitCacheSize(this._getCacheCanvasDimensions()),\n retinaScaling = this.getCanvasRetinaScaling(),\n width = dims.x / this.scaleX / retinaScaling,\n height = dims.y / this.scaleY / retinaScaling,\n pCanvas = createCanvasElementFor({\n // in case width and height are less than 1px, we have to round up.\n // since the pattern is no-repeat, this is fine\n width: Math.ceil(width),\n height: Math.ceil(height),\n });\n\n const pCtx = pCanvas.getContext('2d');\n if (!pCtx) {\n return;\n }\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.scale(\n dims.zoomX / this.scaleX / retinaScaling,\n dims.zoomY / this.scaleY / retinaScaling,\n );\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fillStyle = filler.toLive(ctx)!;\n pCtx.fill();\n ctx.translate(\n -this.width / 2 - this.strokeWidth / 2,\n -this.height / 2 - this.strokeWidth / 2,\n );\n ctx.scale(\n (retinaScaling * this.scaleX) / dims.zoomX,\n (retinaScaling * this.scaleY) / dims.zoomY,\n );\n ctx.strokeStyle = pCtx.createPattern(pCanvas, 'no-repeat') ?? '';\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement() {\n return new Point(this.left + this.width / 2, this.top + this.height / 2);\n }\n\n /**\n * Clones an instance.\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {Promise}\n */\n clone(propertiesToInclude?: string[]): Promise {\n const objectForm = this.toObject(propertiesToInclude);\n return (this.constructor as typeof FabricObject).fromObject(\n objectForm,\n ) as unknown as Promise;\n }\n\n /**\n * Creates an instance of Image out of an object\n * makes use of toCanvasElement.\n * Once this method was based on toDataUrl and loadImage, so it also had a quality\n * and format option. toCanvasElement is faster and produce no loss of quality.\n * If you need to get a real Jpeg or Png from an object, using toDataURL is the right way to do it.\n * toCanvasElement and then toBlob from the obtained canvas is also a good option.\n * @todo fix the export type, it could not be Image but the type that getClass return for 'image'.\n * @param {ObjectToCanvasElementOptions} [options] for clone as image, passed to toDataURL\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {FabricImage} Object cloned as image.\n */\n cloneAsImage(options: ObjectToCanvasElementOptions): FabricImage {\n const canvasEl = this.toCanvasElement(options);\n // TODO: how to import Image w/o an import cycle?\n const ImageClass = classRegistry.getClass('image');\n return new ImageClass(canvasEl);\n }\n\n /**\n * Converts an object into a HTMLCanvas element\n * @param {ObjectToCanvasElementOptions} options Options object\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @param {Boolean} [options.viewportTransform] Account for canvas viewport transform\n * @param {(el?: HTMLCanvasElement) => StaticCanvas} [options.canvasProvider] Create the output canvas\n * @return {HTMLCanvasElement} Returns DOM element with the FabricObject\n */\n toCanvasElement(options: ObjectToCanvasElementOptions = {}) {\n const origParams = saveObjectTransform(this),\n originalGroup = this.group,\n originalShadow = this.shadow,\n abs = Math.abs,\n retinaScaling = options.enableRetinaScaling ? getDevicePixelRatio() : 1,\n multiplier = (options.multiplier || 1) * retinaScaling,\n canvasProvider: (el: HTMLCanvasElement) => StaticCanvas =\n options.canvasProvider ||\n ((el: HTMLCanvasElement) =>\n new StaticCanvas(el, {\n enableRetinaScaling: false,\n renderOnAddRemove: false,\n skipOffscreen: false,\n }));\n delete this.group;\n if (options.withoutTransform) {\n resetObjectTransform(this);\n }\n if (options.withoutShadow) {\n this.shadow = null;\n }\n if (options.viewportTransform) {\n sendObjectToPlane(this, this.getViewportTransform());\n }\n\n this.setCoords();\n const el = createCanvasElement(),\n boundingRect = this.getBoundingRect(),\n shadow = this.shadow,\n shadowOffset = new Point();\n\n if (shadow) {\n const shadowBlur = shadow.blur;\n const scaling = shadow.nonScaling\n ? new Point(1, 1)\n : this.getObjectScaling();\n // consider non scaling shadow.\n shadowOffset.x =\n 2 * Math.round(abs(shadow.offsetX) + shadowBlur) * abs(scaling.x);\n shadowOffset.y =\n 2 * Math.round(abs(shadow.offsetY) + shadowBlur) * abs(scaling.y);\n }\n const width = boundingRect.width + shadowOffset.x,\n height = boundingRect.height + shadowOffset.y;\n // if the current width/height is not an integer\n // we need to make it so.\n el.width = Math.ceil(width);\n el.height = Math.ceil(height);\n const canvas = canvasProvider(el);\n if (options.format === 'jpeg') {\n canvas.backgroundColor = '#fff';\n }\n this.setPositionByOrigin(\n new Point(canvas.width / 2, canvas.height / 2),\n CENTER,\n CENTER,\n );\n const originalCanvas = this.canvas;\n // static canvas and canvas have both an array of InteractiveObjects\n // @ts-expect-error this needs to be fixed somehow, or ignored globally\n canvas._objects = [this];\n this.set('canvas', canvas);\n this.setCoords();\n const canvasEl = canvas.toCanvasElement(multiplier || 1, options);\n this.set('canvas', originalCanvas);\n this.shadow = originalShadow;\n if (originalGroup) {\n this.group = originalGroup;\n }\n this.set(origParams);\n this.setCoords();\n // canvas.dispose will call image.dispose that will nullify the elements\n // since this canvas is a simple element for the process, we remove references\n // to objects in this way in order to avoid object trashing.\n canvas._objects = [];\n // since render has settled it is safe to destroy canvas\n canvas.destroy();\n return canvasEl;\n }\n\n /**\n * Converts an object into a data-url-like string\n * @param {Object} options Options object\n * @param {String} [options.format=png] The format of the output image. Either \"jpeg\" or \"png\"\n * @param {Number} [options.quality=1] Quality level (0..1). Only used for jpeg.\n * @param {Number} [options.multiplier=1] Multiplier to scale by\n * @param {Number} [options.left] Cropping left offset. Introduced in v1.2.14\n * @param {Number} [options.top] Cropping top offset. Introduced in v1.2.14\n * @param {Number} [options.width] Cropping width. Introduced in v1.2.14\n * @param {Number} [options.height] Cropping height. Introduced in v1.2.14\n * @param {Boolean} [options.enableRetinaScaling] Enable retina scaling for clone image. Introduce in 1.6.4\n * @param {Boolean} [options.withoutTransform] Remove current object transform ( no scale , no angle, no flip, no skew ). Introduced in 2.3.4\n * @param {Boolean} [options.withoutShadow] Remove current object shadow. Introduced in 2.4.2\n * @return {String} Returns a data: URL containing a representation of the object in the format specified by options.format\n */\n toDataURL(options: toDataURLOptions = {}) {\n return toDataURL(\n this.toCanvasElement(options),\n options.format || 'png',\n options.quality || 1,\n );\n }\n\n /**\n * Returns true if any of the specified types is identical to the type of an instance\n * @param {String} type Type to check against\n * @return {Boolean}\n */\n isType(...types: string[]) {\n return (\n types.includes((this.constructor as typeof FabricObject).type) ||\n types.includes(this.type)\n );\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance (is 1 unless subclassed)\n */\n complexity() {\n return 1;\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n /**\n * Sets \"angle\" of an instance with centered rotation\n * @param {TDegree} angle Angle value (in degrees)\n */\n rotate(angle: TDegree) {\n const { centeredRotation, originX, originY } = this;\n\n if (centeredRotation) {\n const { x, y } = this.getRelativeCenterPoint();\n this.originX = CENTER;\n this.originY = CENTER;\n this.left = x;\n this.top = y;\n }\n\n this.set('angle', angle);\n\n if (centeredRotation) {\n const { x, y } = this.translateToOriginPoint(\n this.getRelativeCenterPoint(),\n originX,\n originY,\n );\n this.left = x;\n this.top = y;\n this.originX = originX;\n this.originY = originY;\n }\n }\n\n /**\n * This callback function is called by the parent group of an object every\n * time a non-delegated property changes on the group. It is passed the key\n * and value as parameters. Not adding in this function's signature to avoid\n * Travis build error about unused variables.\n */\n setOnGroup() {\n // implemented by sub-classes, as needed.\n }\n\n /**\n * Sets canvas globalCompositeOperation for specific object\n * custom composition operation for the particular object can be specified using globalCompositeOperation property\n * @param {CanvasRenderingContext2D} ctx Rendering canvas context\n */\n _setupCompositeOperation(ctx: CanvasRenderingContext2D) {\n if (this.globalCompositeOperation) {\n ctx.globalCompositeOperation = this.globalCompositeOperation;\n }\n }\n\n /**\n * cancel instance's running animations\n * override if necessary to dispose artifacts such as `clipPath`\n */\n dispose() {\n runningAnimations.cancelByTarget(this);\n this.off();\n this._set('canvas', undefined);\n // clear caches\n this._cacheCanvas && getEnv().dispose(this._cacheCanvas);\n this._cacheCanvas = undefined;\n this._cacheContext = null;\n }\n\n // #region Animation methods\n /**\n * List of properties to consider for animating colors.\n * @type String[]\n */\n static colorProperties: string[] = [FILL, STROKE, 'backgroundColor'];\n\n /**\n * Animates object's properties\n * @param {Record} animatable map of keys and end values\n * @param {Partial>} options\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#animation}\n * @return {Record>} map of animation contexts\n *\n * As object — multiple properties\n *\n * object.animate({ left: ..., top: ... });\n * object.animate({ left: ..., top: ... }, { duration: ... });\n */\n animate(\n animatable: Record,\n options?: Partial>,\n ): Record> {\n return Object.entries(animatable).reduce(\n (acc, [key, endValue]) => {\n acc[key] = this._animate(key, endValue, options);\n return acc;\n },\n {} as Record>,\n );\n }\n\n /**\n * @private\n * @param {String} key Property to animate\n * @param {String} to Value to animate to\n * @param {Object} [options] Options object\n */\n _animate(\n key: string,\n endValue: T,\n options: Partial> = {},\n ): TAnimation {\n const path = key.split('.');\n const propIsColor = (\n this.constructor as typeof FabricObject\n ).colorProperties.includes(path[path.length - 1]);\n const { abort, startValue, onChange, onComplete } = options;\n const animationOptions = {\n ...options,\n target: this,\n // path.reduce... is the current value in case start value isn't provided\n startValue:\n startValue ?? path.reduce((deep: any, key) => deep[key], this),\n endValue,\n abort: abort?.bind(this),\n onChange: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n path.reduce((deep: Record, key, index) => {\n if (index === path.length - 1) {\n deep[key] = value;\n }\n return deep[key];\n }, this);\n onChange &&\n // @ts-expect-error generic callback arg0 is wrong\n onChange(value, valueProgress, durationProgress);\n },\n onComplete: (\n value: number | number[] | string,\n valueProgress: number,\n durationProgress: number,\n ) => {\n this.setCoords();\n onComplete &&\n // @ts-expect-error generic callback arg0 is wrong\n onComplete(value, valueProgress, durationProgress);\n },\n } as AnimationOptions;\n\n return (\n propIsColor\n ? animateColor(animationOptions as ColorAnimationOptions)\n : animate(\n animationOptions as ValueAnimationOptions | ArrayAnimationOptions,\n )\n ) as TAnimation;\n }\n\n // #region Object stacking methods\n\n /**\n * A reference to the parent of the object\n * Used to keep the original parent ref when the object has been added to an ActiveSelection, hence loosing the `group` ref\n */\n declare parent?: Group;\n\n /**\n * Checks if object is descendant of target\n * Should be used instead of {@link Group.contains} or {@link StaticCanvas.contains} for performance reasons\n * @param {TAncestor} target\n * @returns {boolean}\n */\n isDescendantOf(target: TAncestor): boolean {\n const { parent, group } = this;\n return (\n parent === target ||\n group === target ||\n // walk up\n (!!parent && parent.isDescendantOf(target)) ||\n (!!group && group !== parent && group.isDescendantOf(target))\n );\n }\n\n /**\n * @returns {Ancestors} ancestors (excluding `ActiveSelection`) from bottom to top\n */\n getAncestors(): Ancestors {\n const ancestors: TAncestor[] = [];\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let parent: TAncestor | undefined = this;\n do {\n parent = parent.parent;\n parent && ancestors.push(parent);\n } while (parent);\n return ancestors as Ancestors;\n }\n\n /**\n * Compare ancestors\n *\n * @param {StackedObject} other\n * @returns {AncestryComparison} an object that represent the ancestry situation.\n */\n findCommonAncestors(other: T): AncestryComparison {\n if (this === other) {\n return {\n fork: [],\n otherFork: [],\n common: [this, ...this.getAncestors()],\n } as AncestryComparison;\n }\n const ancestors = this.getAncestors();\n const otherAncestors = other.getAncestors();\n // if `this` has no ancestors and `this` is top ancestor of `other` we must handle the following case\n if (\n ancestors.length === 0 &&\n otherAncestors.length > 0 &&\n this === otherAncestors[otherAncestors.length - 1]\n ) {\n return {\n fork: [],\n otherFork: [\n other,\n ...otherAncestors.slice(0, otherAncestors.length - 1),\n ],\n common: [this],\n } as AncestryComparison;\n }\n // compare ancestors\n for (let i = 0, ancestor; i < ancestors.length; i++) {\n ancestor = ancestors[i];\n if (ancestor === other) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n for (let j = 0; j < otherAncestors.length; j++) {\n if (this === otherAncestors[j]) {\n return {\n fork: [],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: [this, ...ancestors],\n } as AncestryComparison;\n }\n if (ancestor === otherAncestors[j]) {\n return {\n fork: [this, ...ancestors.slice(0, i)],\n otherFork: [other, ...otherAncestors.slice(0, j)],\n common: ancestors.slice(i),\n } as AncestryComparison;\n }\n }\n }\n // nothing shared\n return {\n fork: [this, ...ancestors],\n otherFork: [other, ...otherAncestors],\n common: [],\n } as AncestryComparison;\n }\n\n /**\n *\n * @param {StackedObject} other\n * @returns {boolean}\n */\n hasCommonAncestors(other: T): boolean {\n const commonAncestors = this.findCommonAncestors(other);\n return commonAncestors && !!commonAncestors.common.length;\n }\n\n /**\n *\n * @param {FabricObject} other object to compare against\n * @returns {boolean | undefined} if objects do not share a common ancestor or they are strictly equal it is impossible to determine which is in front of the other; in such cases the function returns `undefined`\n */\n isInFrontOf(other: T): boolean | undefined {\n if (this === other) {\n return undefined;\n }\n const ancestorData = this.findCommonAncestors(other);\n\n if (ancestorData.fork.includes(other as any)) {\n return true;\n }\n if (ancestorData.otherFork.includes(this as any)) {\n return false;\n }\n // if there isn't a common ancestor, we take the canvas.\n // if there is no canvas, there is nothing to compare\n const firstCommonAncestor = ancestorData.common[0] || this.canvas;\n if (!firstCommonAncestor) {\n return undefined;\n }\n const headOfFork = ancestorData.fork.pop(),\n headOfOtherFork = ancestorData.otherFork.pop(),\n thisIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfFork as any,\n ),\n otherIndex = (firstCommonAncestor as TCollection)._objects.indexOf(\n headOfOtherFork as any,\n );\n return thisIndex > -1 && thisIndex > otherIndex;\n }\n\n // #region Serialization\n /**\n * Define a list of custom properties that will be serialized when\n * instance.toObject() gets called\n */\n static customProperties: string[] = [];\n\n /**\n * Returns an object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject(propertiesToInclude: any[] = []): any {\n const propertiesToSerialize = propertiesToInclude.concat(\n FabricObject.customProperties,\n (this.constructor as typeof FabricObject).customProperties || [],\n );\n let clipPathData: Partial | undefined;\n const NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n const {\n clipPath,\n fill,\n stroke,\n shadow,\n strokeDashArray,\n left,\n top,\n originX,\n originY,\n width,\n height,\n strokeWidth,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit,\n scaleX,\n scaleY,\n angle,\n flipX,\n flipY,\n opacity,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX,\n skewY,\n } = this;\n if (clipPath && !clipPath.excludeFromExport) {\n clipPathData = clipPath.toObject(\n propertiesToSerialize.concat('inverted', 'absolutePositioned'),\n );\n }\n const toFixedBound = (val: number) => toFixed(val, NUM_FRACTION_DIGITS);\n const object = {\n ...pick(this, propertiesToSerialize as (keyof this)[]),\n type: (this.constructor as typeof FabricObject).type,\n version: VERSION,\n originX,\n originY,\n left: toFixedBound(left),\n top: toFixedBound(top),\n width: toFixedBound(width),\n height: toFixedBound(height),\n fill: isSerializableFiller(fill) ? fill.toObject() : fill,\n stroke: isSerializableFiller(stroke) ? stroke.toObject() : stroke,\n strokeWidth: toFixedBound(strokeWidth),\n strokeDashArray: strokeDashArray\n ? strokeDashArray.concat()\n : strokeDashArray,\n strokeLineCap,\n strokeDashOffset,\n strokeLineJoin,\n strokeUniform,\n strokeMiterLimit: toFixedBound(strokeMiterLimit),\n scaleX: toFixedBound(scaleX),\n scaleY: toFixedBound(scaleY),\n angle: toFixedBound(angle),\n flipX,\n flipY,\n opacity: toFixedBound(opacity),\n shadow: shadow ? shadow.toObject() : shadow,\n visible,\n backgroundColor,\n fillRule,\n paintFirst,\n globalCompositeOperation,\n skewX: toFixedBound(skewX),\n skewY: toFixedBound(skewY),\n ...(clipPathData ? { clipPath: clipPathData } : null),\n };\n\n return !this.includeDefaultValues\n ? this._removeDefaultValues(object)\n : object;\n }\n\n /**\n * Returns (dataless) object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toDatalessObject(propertiesToInclude?: any[]): any {\n // will be overwritten by subclasses\n return this.toObject(propertiesToInclude);\n }\n\n /**\n * @private\n * @param {Object} object\n */\n _removeDefaultValues(object: T): Partial {\n // getDefaults() ( get from static ownDefaults ) should win over prototype since anyway they get assigned to instance\n // ownDefault vs prototype is swappable only if you change all the fabric objects consistently.\n const defaults = (this.constructor as typeof FabricObject).getDefaults();\n const hasStaticDefaultValues = Object.keys(defaults).length > 0;\n const baseValues = hasStaticDefaultValues\n ? defaults\n : Object.getPrototypeOf(this);\n\n return pickBy(object, (value, key) => {\n if (key === LEFT || key === TOP || key === 'type') {\n return true;\n }\n const baseValue = baseValues[key];\n return (\n value !== baseValue &&\n // basically a check for [] === []\n !(\n Array.isArray(value) &&\n Array.isArray(baseValue) &&\n value.length === 0 &&\n baseValue.length === 0\n )\n );\n });\n }\n\n /**\n * Returns a string representation of an instance\n * @return {String}\n */\n toString() {\n return `#<${(this.constructor as typeof FabricObject).type}>`;\n }\n\n /**\n *\n * @param {Function} klass\n * @param {object} object\n * @param {object} [options]\n * @param {string} [options.extraParam] property to pass as first argument to the constructor\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static _fromObject(\n { type, ...serializedObjectOptions }: Record,\n { extraParam, ...options }: Abortable & { extraParam?: string } = {},\n ): Promise {\n return enlivenObjectEnlivables(serializedObjectOptions, options).then(\n (enlivedObjectOptions) => {\n // from the resulting enlived options, extract options.extraParam to arg0\n // to avoid accidental overrides later\n if (extraParam) {\n delete enlivedObjectOptions[extraParam];\n return new this(\n serializedObjectOptions[extraParam],\n // @ts-expect-error different signature\n enlivedObjectOptions,\n );\n } else {\n return new this(enlivedObjectOptions);\n }\n },\n ) as Promise;\n }\n\n /**\n *\n * @param {object} object\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n object: T,\n options?: Abortable,\n ) {\n return this._fromObject(object, options);\n }\n}\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n","import type {\n TModificationEvents,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\n/**\n * Wrap an action handler with firing an event if the action is performed\n * @param {TModificationEvents} eventName the event we want to fire\n * @param {TransformActionHandler} actionHandler the function to wrap\n * @param {object} extraEventInfo extra information to pas to the event handler\n * @return {TransformActionHandler} a function with an action handler signature\n */\nexport const wrapWithFireEvent = <\n T extends Transform,\n P extends object = Record,\n>(\n eventName: TModificationEvents,\n actionHandler: TransformActionHandler,\n extraEventInfo?: P,\n) => {\n return ((eventData, transform, x, y) => {\n const actionPerformed = actionHandler(eventData, transform, x, y);\n if (actionPerformed) {\n fireEvent(eventName, {\n ...commonEventInfo(eventData, transform, x, y),\n ...extraEventInfo,\n });\n }\n return actionPerformed;\n }) as TransformActionHandler;\n};\n","import type { Transform, TransformActionHandler } from '../EventTypeDefs';\n\n/**\n * Wrap an action handler with saving/restoring object position on the transform.\n * this is the code that permits to objects to keep their position while transforming.\n * @param {Function} actionHandler the function to wrap\n * @return {Function} a function with an action handler signature\n */\nexport function wrapWithFixedAnchor(\n actionHandler: TransformActionHandler,\n) {\n return ((eventData, transform, x, y) => {\n const { target, originX, originY } = transform,\n centerPoint = target.getRelativeCenterPoint(),\n constraint = target.translateToOriginPoint(centerPoint, originX, originY),\n actionPerformed = actionHandler(eventData, transform, x, y);\n // flipping requires to change the transform origin, so we read from the mutated transform\n // instead of leveraging the one destructured before\n target.setPositionByOrigin(\n constraint,\n transform.originX,\n transform.originY,\n );\n return actionPerformed;\n }) as TransformActionHandler;\n}\n","import type { TransformActionHandler } from '../EventTypeDefs';\nimport { CENTER, LEFT, RESIZING, RIGHT } from '../constants';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { getLocalPoint, isTransformCentered } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Action handler to change object's width\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const changeObjectWidth: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n const localPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // make sure the control changes width ONLY from it's side of target\n if (\n resolveOrigin(transform.originX) === resolveOrigin(CENTER) ||\n (resolveOrigin(transform.originX) === resolveOrigin(RIGHT) &&\n localPoint.x < 0) ||\n (resolveOrigin(transform.originX) === resolveOrigin(LEFT) &&\n localPoint.x > 0)\n ) {\n const { target } = transform,\n strokePadding =\n target.strokeWidth / (target.strokeUniform ? target.scaleX : 1),\n multiplier = isTransformCentered(transform) ? 2 : 1,\n oldWidth = target.width,\n newWidth =\n Math.abs((localPoint.x * multiplier) / target.scaleX) - strokePadding;\n target.set('width', Math.max(newWidth, 1));\n // check against actual target width in case `newWidth` was rejected\n return oldWidth !== target.width;\n }\n return false;\n};\n\nexport const changeWidth = wrapWithFireEvent(\n RESIZING,\n wrapWithFixedAnchor(changeObjectWidth),\n);\n","import { FILL, STROKE, twoMathPi } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport type { Control } from './Control';\n\nexport type ControlRenderingStyleOverride = Partial<\n Pick<\n InteractiveFabricObject,\n | 'cornerStyle'\n | 'cornerSize'\n | 'cornerColor'\n | 'cornerStrokeColor'\n | 'cornerDashArray'\n | 'transparentCorners'\n >\n>;\n\nexport type ControlRenderer<\n O extends InteractiveFabricObject = InteractiveFabricObject,\n> = (\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: O,\n) => void;\n\n/**\n * Render a round control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderCircleControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor);\n let myLeft = left,\n myTop = top,\n size;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n // TODO: use proper ellipse code.\n if (xSize > ySize) {\n size = xSize;\n ctx.scale(1.0, ySize / xSize);\n myTop = (top * xSize) / ySize;\n } else if (ySize > xSize) {\n size = ySize;\n ctx.scale(xSize / ySize, 1.0);\n myLeft = (left * ySize) / xSize;\n } else {\n size = xSize;\n }\n ctx.beginPath();\n ctx.arc(myLeft, myTop, size / 2, 0, twoMathPi, false);\n ctx[methodName]();\n if (stroke) {\n ctx.stroke();\n }\n ctx.restore();\n}\n\n/**\n * Render a square control, as per fabric features.\n * This function is written to respect object properties like transparentCorners, cornerSize\n * cornerColor, cornerStrokeColor\n * plus the addition of offsetY and offsetX.\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @param {Number} left x coordinate where the control center should be\n * @param {Number} top y coordinate where the control center should be\n * @param {Object} styleOverride override for FabricObject controls style\n * @param {FabricObject} fabricObject the fabric object for which we are rendering controls\n */\nexport function renderSquareControl(\n this: Control,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride,\n fabricObject: InteractiveFabricObject,\n) {\n styleOverride = styleOverride || {};\n const xSize =\n this.sizeX || styleOverride.cornerSize || fabricObject.cornerSize,\n ySize = this.sizeY || styleOverride.cornerSize || fabricObject.cornerSize,\n transparentCorners =\n typeof styleOverride.transparentCorners !== 'undefined'\n ? styleOverride.transparentCorners\n : fabricObject.transparentCorners,\n methodName = transparentCorners ? STROKE : FILL,\n stroke =\n !transparentCorners &&\n (styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor),\n xSizeBy2 = xSize / 2,\n ySizeBy2 = ySize / 2;\n ctx.save();\n ctx.fillStyle = styleOverride.cornerColor || fabricObject.cornerColor || '';\n ctx.strokeStyle =\n styleOverride.cornerStrokeColor || fabricObject.cornerStrokeColor || '';\n ctx.translate(left, top);\n // angle is relative to canvas plane\n const angle = fabricObject.getTotalAngle();\n ctx.rotate(degreesToRadians(angle));\n // this does not work, and fixed with ( && ) does not make sense.\n // to have real transparent corners we need the controls on upperCanvas\n // transparentCorners || ctx.clearRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n ctx[`${methodName}Rect`](-xSizeBy2, -ySizeBy2, xSize, ySize);\n if (stroke) {\n ctx.strokeRect(-xSizeBy2, -ySizeBy2, xSize, ySize);\n }\n ctx.restore();\n}\n","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type {\n ControlActionHandler,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { Intersection } from '../Intersection';\nimport { Point } from '../Point';\nimport { SCALE } from '../constants';\nimport type { InteractiveFabricObject } from '../shapes/Object/InteractiveObject';\nimport type { TCornerPoint, TDegree, TMat2D } from '../typedefs';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { renderCircleControl, renderSquareControl } from './controlRendering';\n\nexport class Control {\n /**\n * keep track of control visibility.\n * mainly for backward compatibility.\n * if you do not want to see a control, you can remove it\n * from the control set.\n * @type {Boolean}\n * @default true\n */\n visible = true;\n\n /**\n * Name of the action that the control will likely execute.\n * This is optional. FabricJS uses to identify what the user is doing for some\n * extra optimizations. If you are writing a custom control and you want to know\n * somewhere else in the code what is going on, you can use this string here.\n * you can also provide a custom getActionName if your control run multiple actions\n * depending on some external state.\n * default to scale since is the most common, used on 4 corners by default\n * @type {String}\n * @default 'scale'\n */\n actionName = SCALE;\n\n /**\n * Drawing angle of the control.\n * NOT used for now, but name marked as needed for internal logic\n * example: to reuse the same drawing function for different rotated controls\n * @type {Number}\n * @default 0\n */\n angle = 0;\n\n /**\n * Relative position of the control. X\n * 0,0 is the center of the Object, while -0.5 (left) or 0.5 (right) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n x = 0;\n\n /**\n * Relative position of the control. Y\n * 0,0 is the center of the Object, while -0.5 (top) or 0.5 (bottom) are the extremities\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n y = 0;\n\n /**\n * Horizontal offset of the control from the defined position. In pixels\n * Positive offset moves the control to the right, negative to the left.\n * It used when you want to have position of control that does not scale with\n * the bounding box. Example: rotation control is placed at x:0, y: 0.5 on\n * the boundind box, with an offset of 30 pixels vertically. Those 30 pixels will\n * stay 30 pixels no matter how the object is big. Another example is having 2\n * controls in the corner, that stay in the same position when the object scale.\n * of the bounding box.\n * @type {Number}\n * @default 0\n */\n offsetX = 0;\n\n /**\n * Vertical offset of the control from the defined position. In pixels\n * Positive offset moves the control to the bottom, negative to the top.\n * @type {Number}\n * @default 0\n */\n offsetY = 0;\n\n /**\n * Sets the length of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeX = 0;\n\n /**\n * Sets the height of the control. If null, defaults to object's cornerSize.\n * Expects both sizeX and sizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n sizeY = 0;\n\n /**\n * Sets the length of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeX = 0;\n\n /**\n * Sets the height of the touch area of the control. If null, defaults to object's touchCornerSize.\n * Expects both touchSizeX and touchSizeY to be set when set.\n * @type {?Number}\n * @default null\n */\n touchSizeY = 0;\n\n /**\n * Css cursor style to display when the control is hovered.\n * if the method `cursorStyleHandler` is provided, this property is ignored.\n * @type {String}\n * @default 'crosshair'\n */\n cursorStyle = 'crosshair';\n\n /**\n * If controls has an offsetY or offsetX, draw a line that connects\n * the control to the bounding box\n * @type {Boolean}\n * @default false\n */\n withConnection = false;\n\n constructor(options?: Partial) {\n Object.assign(this, options);\n }\n\n /**\n * The control actionHandler, provide one to handle action ( control being moved )\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare actionHandler: TransformActionHandler;\n\n /**\n * The control handler for mouse down, provide one to handle mouse down on control\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseDownHandler?: ControlActionHandler;\n\n /**\n * The control mouseUpHandler, provide one to handle an effect on mouse up.\n * @param {Event} eventData the native mouse event\n * @param {Transform} transformData properties of the current transform\n * @param {Number} x x position of the cursor\n * @param {Number} y y position of the cursor\n * @return {Boolean} true if the action/event modified the object\n */\n declare mouseUpHandler?: ControlActionHandler;\n\n shouldActivate(\n controlKey: string,\n fabricObject: InteractiveFabricObject,\n pointer: Point,\n { tl, tr, br, bl }: TCornerPoint,\n ) {\n // TODO: locking logic can be handled here instead of in the control handler logic\n return (\n fabricObject.canvas?.getActiveObject() === fabricObject &&\n fabricObject.isControlVisible(controlKey) &&\n Intersection.isPointInPolygon(pointer, [tl, tr, br, bl])\n );\n }\n\n /**\n * Returns control actionHandler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getActionHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): TransformActionHandler | undefined {\n return this.actionHandler;\n }\n\n /**\n * Returns control mouseDown handler\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseDownHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseDownHandler;\n }\n\n /**\n * Returns control mouseUp handler.\n * During actions the fabricObject or the control can be of different obj\n * @param {Event} eventData the native mouse event\n * @param {FabricObject} fabricObject on which the control is displayed\n * @param {Control} control control for which the action handler is being asked\n * @return {Function} the action handler\n */\n getMouseUpHandler(\n eventData: TPointerEvent,\n fabricObject: InteractiveFabricObject,\n control: Control,\n ): ControlActionHandler | undefined {\n return this.mouseUpHandler;\n }\n\n /**\n * Returns control cursorStyle for css using cursorStyle. If you need a more elaborate\n * function you can pass one in the constructor\n * the cursorStyle property\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n cursorStyleHandler(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.cursorStyle;\n }\n\n /**\n * Returns the action name. The basic implementation just return the actionName property.\n * @param {Event} eventData the native mouse event\n * @param {Control} control the current control ( likely this)\n * @param {FabricObject} object on which the control is displayed\n * @return {String}\n */\n getActionName(\n eventData: TPointerEvent,\n control: Control,\n fabricObject: InteractiveFabricObject,\n ) {\n return control.actionName;\n }\n\n /**\n * Returns controls visibility\n * @param {FabricObject} object on which the control is displayed\n * @param {String} controlKey key where the control is memorized on the\n * @return {Boolean}\n */\n getVisibility(fabricObject: InteractiveFabricObject, controlKey: string) {\n return fabricObject._controlsVisibility?.[controlKey] ?? this.visible;\n }\n\n /**\n * Sets controls visibility\n * @param {Boolean} visibility for the object\n * @return {Void}\n */\n setVisibility(\n visibility: boolean,\n name: string,\n fabricObject: InteractiveFabricObject,\n ) {\n this.visible = visibility;\n }\n\n positionHandler(\n dim: Point,\n finalMatrix: TMat2D,\n fabricObject: InteractiveFabricObject,\n currentControl: Control,\n ) {\n return new Point(\n this.x * dim.x + this.offsetX,\n this.y * dim.y + this.offsetY,\n ).transform(finalMatrix);\n }\n\n /**\n * Returns the coords for this control based on object values.\n * @param {Number} objectAngle angle from the fabric object holding the control\n * @param {Number} objectCornerSize cornerSize from the fabric object holding the control (or touchCornerSize if\n * isTouch is true)\n * @param {Number} centerX x coordinate where the control center should be\n * @param {Number} centerY y coordinate where the control center should be\n * @param {boolean} isTouch true if touch corner, false if normal corner\n */\n calcCornerCoords(\n angle: TDegree,\n objectCornerSize: number,\n centerX: number,\n centerY: number,\n isTouch: boolean,\n fabricObject: InteractiveFabricObject,\n ) {\n const t = multiplyTransformMatrixArray([\n createTranslateMatrix(centerX, centerY),\n createRotateMatrix({ angle }),\n createScaleMatrix(\n (isTouch ? this.touchSizeX : this.sizeX) || objectCornerSize,\n (isTouch ? this.touchSizeY : this.sizeY) || objectCornerSize,\n ),\n ]);\n return {\n tl: new Point(-0.5, -0.5).transform(t),\n tr: new Point(0.5, -0.5).transform(t),\n br: new Point(0.5, 0.5).transform(t),\n bl: new Point(-0.5, 0.5).transform(t),\n };\n }\n\n /**\n * Render function for the control.\n * When this function runs the context is unscaled. unrotate. Just retina scaled.\n * all the functions will have to translate to the point left,top before starting Drawing\n * if they want to draw a control where the position is detected.\n * left and top are the result of the positionHandler function\n * @param {RenderingContext2D} ctx the context where the control will be drawn\n * @param {Number} left position of the canvas where we are about to render the control.\n * @param {Number} top position of the canvas where we are about to render the control.\n * @param {Object} styleOverride\n * @param {FabricObject} fabricObject the object where the control is about to be rendered\n */\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: InteractiveFabricObject,\n ) {\n styleOverride = styleOverride || {};\n switch (styleOverride.cornerStyle || fabricObject.cornerStyle) {\n case 'circle':\n renderCircleControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n break;\n default:\n renderSquareControl.call(\n this,\n ctx,\n left,\n top,\n styleOverride,\n fabricObject,\n );\n }\n }\n}\n","import type {\n ControlCursorCallback,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { ROTATING } from '../constants';\nimport { radiansToDegrees } from '../util/misc/radiansDegreesConversion';\nimport { isLocked, NOT_ALLOWED_CURSOR } from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\n\n/**\n * Find the correct style for the control that is used for rotation.\n * this function is very simple and it just take care of not-allowed or standard cursor\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const rotationStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (fabricObject.lockRotation) {\n return NOT_ALLOWED_CURSOR;\n }\n return control.cursorStyle;\n};\n\n/**\n * Action handler for rotation and snapping, without anchor point.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n * @private\n */\nconst rotateObjectWithSnapping: TransformActionHandler = (\n eventData,\n { target, ex, ey, theta, originX, originY },\n x,\n y,\n) => {\n const pivotPoint = target.translateToOriginPoint(\n target.getRelativeCenterPoint(),\n originX,\n originY,\n );\n\n if (isLocked(target, 'lockRotation')) {\n return false;\n }\n\n const lastAngle = Math.atan2(ey - pivotPoint.y, ex - pivotPoint.x),\n curAngle = Math.atan2(y - pivotPoint.y, x - pivotPoint.x);\n let angle = radiansToDegrees(curAngle - lastAngle + theta);\n\n if (target.snapAngle && target.snapAngle > 0) {\n const snapAngle = target.snapAngle,\n snapThreshold = target.snapThreshold || snapAngle,\n rightAngleLocked = Math.ceil(angle / snapAngle) * snapAngle,\n leftAngleLocked = Math.floor(angle / snapAngle) * snapAngle;\n\n if (Math.abs(angle - leftAngleLocked) < snapThreshold) {\n angle = leftAngleLocked;\n } else if (Math.abs(angle - rightAngleLocked) < snapThreshold) {\n angle = rightAngleLocked;\n }\n }\n\n // normalize angle to positive value\n if (angle < 0) {\n angle = 360 + angle;\n }\n angle %= 360;\n\n const hasRotated = target.angle !== angle;\n // TODO: why aren't we using set?\n target.angle = angle;\n return hasRotated;\n};\n\nexport const rotationWithSnapping = wrapWithFireEvent(\n ROTATING,\n wrapWithFixedAnchor(rotateObjectWithSnapping),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxis } from '../typedefs';\nimport type { Canvas } from '../canvas/Canvas';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n invertOrigin,\n isLocked,\n isTransformCentered,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport { SCALE_X, SCALE_Y, SCALING } from '../constants';\n\ntype ScaleTransform = Transform & {\n gestureScale?: number;\n signX?: number;\n signY?: number;\n};\n\ntype ScaleBy = TAxis | 'equally' | '' | undefined;\n\n/**\n * Inspect event and fabricObject properties to understand if the scaling action\n * @param {Event} eventData from the user action\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @return {Boolean} true if scale is proportional\n */\nexport function scaleIsProportional(\n eventData: TPointerEvent,\n fabricObject: FabricObject,\n): boolean {\n const canvas = fabricObject.canvas as Canvas,\n uniformIsToggled = eventData[canvas.uniScaleKey!];\n return (\n (canvas.uniformScaling && !uniformIsToggled) ||\n (!canvas.uniformScaling && uniformIsToggled)\n );\n}\n\n/**\n * Inspect fabricObject to understand if the current scaling action is allowed\n * @param {FabricObject} fabricObject the fabric object about to scale\n * @param {String} by 'x' or 'y' or ''\n * @param {Boolean} scaleProportionally true if we are trying to scale proportionally\n * @return {Boolean} true if scaling is not allowed at current conditions\n */\nexport function scalingIsForbidden(\n fabricObject: FabricObject,\n by: ScaleBy,\n scaleProportionally: boolean,\n) {\n const lockX = isLocked(fabricObject, 'lockScalingX'),\n lockY = isLocked(fabricObject, 'lockScalingY');\n if (lockX && lockY) {\n return true;\n }\n if (!by && (lockX || lockY) && scaleProportionally) {\n return true;\n }\n if (lockX && by === 'x') {\n return true;\n }\n if (lockY && by === 'y') {\n return true;\n }\n // code crashes because of a division by 0 if a 0 sized object is scaled\n // forbid to prevent scaling to happen. ISSUE-9475\n const { width, height, strokeWidth } = fabricObject;\n if (width === 0 && strokeWidth === 0 && by !== 'y') {\n return true;\n }\n if (height === 0 && strokeWidth === 0 && by !== 'x') {\n return true;\n }\n return false;\n}\n\nconst scaleMap = ['e', 'se', 's', 'sw', 'w', 'nw', 'n', 'ne', 'e'];\n\n/**\n * return the correct cursor style for the scale action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n const scaleProportionally = scaleIsProportional(eventData, fabricObject),\n by =\n control.x !== 0 && control.y === 0\n ? 'x'\n : control.x === 0 && control.y !== 0\n ? 'y'\n : '';\n if (scalingIsForbidden(fabricObject, by, scaleProportionally)) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control);\n return `${scaleMap[n]}-resize`;\n};\n\n/**\n * Basic scaling logic, reused with different constrain for scaling X,Y, freely or equally.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @param {Object} options additional information for scaling\n * @param {String} options.by 'x', 'y', 'equally' or '' to indicate type of scaling\n * @return {Boolean} true if some change happened\n * @private\n */\nfunction scaleObject(\n eventData: TPointerEvent,\n transform: ScaleTransform,\n x: number,\n y: number,\n options: { by?: ScaleBy } = {},\n) {\n const target = transform.target,\n by = options.by,\n scaleProportionally = scaleIsProportional(eventData, target),\n forbidScaling = scalingIsForbidden(target, by, scaleProportionally);\n let newPoint, scaleX, scaleY, dim, signX, signY;\n\n if (forbidScaling) {\n return false;\n }\n if (transform.gestureScale) {\n scaleX = transform.scaleX * transform.gestureScale;\n scaleY = transform.scaleY * transform.gestureScale;\n } else {\n newPoint = getLocalPoint(\n transform,\n transform.originX,\n transform.originY,\n x,\n y,\n );\n // use of sign: We use sign to detect change of direction of an action. sign usually change when\n // we cross the origin point with the mouse. So a scale flip for example. There is an issue when scaling\n // by center and scaling using one middle control ( default: mr, mt, ml, mb), the mouse movement can easily\n // cross many time the origin point and flip the object. so we need a way to filter out the noise.\n // This ternary here should be ok to filter out X scaling when we want Y only and vice versa.\n signX = by !== 'y' ? Math.sign(newPoint.x || transform.signX || 1) : 1;\n signY = by !== 'x' ? Math.sign(newPoint.y || transform.signY || 1) : 1;\n if (!transform.signX) {\n transform.signX = signX;\n }\n if (!transform.signY) {\n transform.signY = signY;\n }\n\n if (\n isLocked(target, 'lockScalingFlip') &&\n (transform.signX !== signX || transform.signY !== signY)\n ) {\n return false;\n }\n\n dim = target._getTransformedDimensions();\n // missing detection of flip and logic to switch the origin\n if (scaleProportionally && !by) {\n // uniform scaling\n const distance = Math.abs(newPoint.x) + Math.abs(newPoint.y),\n { original } = transform,\n originalDistance =\n Math.abs((dim.x * original.scaleX) / target.scaleX) +\n Math.abs((dim.y * original.scaleY) / target.scaleY),\n scale = distance / originalDistance;\n scaleX = original.scaleX * scale;\n scaleY = original.scaleY * scale;\n } else {\n scaleX = Math.abs((newPoint.x * target.scaleX) / dim.x);\n scaleY = Math.abs((newPoint.y * target.scaleY) / dim.y);\n }\n // if we are scaling by center, we need to double the scale\n if (isTransformCentered(transform)) {\n scaleX *= 2;\n scaleY *= 2;\n }\n if (transform.signX !== signX && by !== 'y') {\n transform.originX = invertOrigin(transform.originX);\n scaleX *= -1;\n transform.signX = signX;\n }\n if (transform.signY !== signY && by !== 'x') {\n transform.originY = invertOrigin(transform.originY);\n scaleY *= -1;\n transform.signY = signY;\n }\n }\n // minScale is taken care of in the setter.\n const oldScaleX = target.scaleX,\n oldScaleY = target.scaleY;\n if (!by) {\n !isLocked(target, 'lockScalingX') && target.set(SCALE_X, scaleX);\n !isLocked(target, 'lockScalingY') && target.set(SCALE_Y, scaleY);\n } else {\n // forbidden cases already handled on top here.\n by === 'x' && target.set(SCALE_X, scaleX);\n by === 'y' && target.set(SCALE_Y, scaleY);\n }\n return oldScaleX !== target.scaleX || oldScaleY !== target.scaleY;\n}\n\n/**\n * Generic scaling logic, to scale from corners either equally or freely.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scaleObjectFromCorner: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y);\n};\n\n/**\n * Scaling logic for the X axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'x' });\n};\n\n/**\n * Scaling logic for the Y axis.\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nconst scaleObjectY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return scaleObject(eventData, transform, x, y, { by: 'y' });\n};\n\nexport const scalingEqually = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectFromCorner),\n);\n\nexport const scalingX = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectX),\n);\n\nexport const scalingY = wrapWithFireEvent(\n SCALING,\n wrapWithFixedAnchor(scaleObjectY),\n);\n","import type {\n ControlCursorCallback,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { Point } from '../Point';\nimport type { TAxis, TAxisKey } from '../typedefs';\nimport {\n degreesToRadians,\n radiansToDegrees,\n} from '../util/misc/radiansDegreesConversion';\nimport {\n findCornerQuadrant,\n getLocalPoint,\n isLocked,\n NOT_ALLOWED_CURSOR,\n} from './util';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { wrapWithFixedAnchor } from './wrapWithFixedAnchor';\nimport {\n CENTER,\n SCALE_X,\n SCALE_Y,\n SKEWING,\n SKEW_X,\n SKEW_Y,\n} from '../constants';\n\nexport type SkewTransform = Transform & { skewingSide: -1 | 1 };\n\nconst AXIS_KEYS: Record<\n TAxis,\n {\n counterAxis: TAxis;\n scale: TAxisKey<'scale'>;\n skew: TAxisKey<'skew'>;\n lockSkewing: TAxisKey<'lockSkewing'>;\n origin: TAxisKey<'origin'>;\n flip: TAxisKey<'flip'>;\n }\n> = {\n x: {\n counterAxis: 'y',\n scale: SCALE_X,\n skew: SKEW_X,\n lockSkewing: 'lockSkewingX',\n origin: 'originX',\n flip: 'flipX',\n },\n y: {\n counterAxis: 'x',\n scale: SCALE_Y,\n skew: SKEW_Y,\n lockSkewing: 'lockSkewingY',\n origin: 'originY',\n flip: 'flipY',\n },\n};\n\nconst skewMap = ['ns', 'nesw', 'ew', 'nwse'];\n\n/**\n * return the correct cursor style for the skew action\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const skewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n if (control.x !== 0 && isLocked(fabricObject, 'lockSkewingY')) {\n return NOT_ALLOWED_CURSOR;\n }\n if (control.y !== 0 && isLocked(fabricObject, 'lockSkewingX')) {\n return NOT_ALLOWED_CURSOR;\n }\n const n = findCornerQuadrant(fabricObject, control) % 4;\n return `${skewMap[n]}-resize`;\n};\n\n/**\n * Since skewing is applied before scaling, calculations are done in a scaleless plane\n * @see https://github.com/fabricjs/fabric.js/pull/8380\n */\nfunction skewObject(\n axis: TAxis,\n { target, ex, ey, skewingSide, ...transform }: SkewTransform,\n pointer: Point,\n) {\n const { skew: skewKey } = AXIS_KEYS[axis],\n offset = pointer\n .subtract(new Point(ex, ey))\n .divide(new Point(target.scaleX, target.scaleY))[axis],\n skewingBefore = target[skewKey],\n skewingStart = transform[skewKey],\n shearingStart = Math.tan(degreesToRadians(skewingStart)),\n // let a, b be the size of target\n // let a' be the value of a after applying skewing\n // then:\n // a' = a + b * skewA => skewA = (a' - a) / b\n // the value b is tricky since skewY is applied before skewX\n b =\n axis === 'y'\n ? target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n // since skewY is applied before skewX, b (=width) is not affected by skewX\n skewX: 0,\n }).x\n : target._getTransformedDimensions({\n scaleX: 1,\n scaleY: 1,\n }).y;\n\n const shearing =\n (2 * offset * skewingSide) /\n // we max out fractions to safeguard from asymptotic behavior\n Math.max(b, 1) +\n // add starting state\n shearingStart;\n\n const skewing = radiansToDegrees(Math.atan(shearing));\n\n target.set(skewKey, skewing);\n const changed = skewingBefore !== target[skewKey];\n\n if (changed && axis === 'y') {\n // we don't want skewing to affect scaleX\n // so we factor it by the inverse skewing diff to make it seem unchanged to the viewer\n const { skewX, scaleX } = target,\n dimBefore = target._getTransformedDimensions({ skewY: skewingBefore }),\n dimAfter = target._getTransformedDimensions(),\n compensationFactor = skewX !== 0 ? dimBefore.x / dimAfter.x : 1;\n compensationFactor !== 1 &&\n target.set(SCALE_X, compensationFactor * scaleX);\n }\n\n return changed;\n}\n\n/**\n * Wrapped Action handler for skewing on a given axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nfunction skewHandler(\n axis: TAxis,\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n) {\n const { target } = transform,\n {\n counterAxis,\n origin: originKey,\n lockSkewing: lockSkewingKey,\n skew: skewKey,\n flip: flipKey,\n } = AXIS_KEYS[axis];\n if (isLocked(target, lockSkewingKey)) {\n return false;\n }\n\n const { origin: counterOriginKey, flip: counterFlipKey } =\n AXIS_KEYS[counterAxis],\n counterOriginFactor =\n resolveOrigin(transform[counterOriginKey]) *\n (target[counterFlipKey] ? -1 : 1),\n // if the counter origin is top/left (= -0.5) then we are skewing x/y values on the bottom/right side of target respectively.\n // if the counter origin is bottom/right (= 0.5) then we are skewing x/y values on the top/left side of target respectively.\n // skewing direction on the top/left side of target is OPPOSITE to the direction of the movement of the pointer,\n // so we factor skewing direction by this value.\n skewingSide = (-Math.sign(counterOriginFactor) *\n (target[flipKey] ? -1 : 1)) as 1 | -1,\n skewingDirection =\n ((target[skewKey] === 0 &&\n // in case skewing equals 0 we use the pointer offset from target center to determine the direction of skewing\n getLocalPoint(transform, CENTER, CENTER, x, y)[axis] > 0) ||\n // in case target has skewing we use that as the direction\n target[skewKey] > 0\n ? 1\n : -1) * skewingSide,\n // anchor to the opposite side of the skewing direction\n // normalize value from [-1, 1] to origin value [0, 1]\n origin = -skewingDirection * 0.5 + 0.5;\n\n const finalHandler = wrapWithFireEvent(\n SKEWING,\n wrapWithFixedAnchor((eventData, transform, x, y) =>\n skewObject(axis, transform, new Point(x, y)),\n ),\n );\n\n return finalHandler(\n eventData,\n {\n ...transform,\n [originKey]: origin,\n skewingSide,\n },\n x,\n y,\n );\n}\n\n/**\n * Wrapped Action handler for skewing on the X axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('x', eventData, transform, x, y);\n};\n\n/**\n * Wrapped Action handler for skewing on the Y axis, takes care of the\n * skew direction and determines the correct transform origin for the anchor point\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const skewHandlerY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return skewHandler('y', eventData, transform, x, y);\n};\n","import type {\n ControlCallback,\n ControlCursorCallback,\n TPointerEvent,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { SCALE_X, SCALE_Y, SKEW_X, SKEW_Y } from '../constants';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TAxisKey } from '../typedefs';\nimport { scaleCursorStyleHandler, scalingX, scalingY } from './scale';\nimport { skewCursorStyleHandler, skewHandlerX, skewHandlerY } from './skew';\n\nfunction isAltAction(eventData: TPointerEvent, target: FabricObject) {\n return eventData[target.canvas!.altActionKey!];\n}\n\n/**\n * Inspect event, control and fabricObject to return the correct action name\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} an action name\n */\nexport const scaleOrSkewActionName: ControlCallback<\n TAxisKey<'skew' | 'scale'> | ''\n> = (eventData, control, fabricObject) => {\n const isAlternative = isAltAction(eventData, fabricObject);\n if (control.x === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_X : SCALE_Y;\n }\n if (control.y === 0) {\n // then is scaleY or skewX\n return isAlternative ? SKEW_Y : SCALE_X;\n }\n return '';\n};\n\n/**\n * Combine skew and scale style handlers to cover fabric standard use case\n * @param {Event} eventData the javascript event that is causing the scale\n * @param {Control} control the control that is interested in the action\n * @param {FabricObject} fabricObject the fabric object that is interested in the action\n * @return {String} a valid css string for the cursor\n */\nexport const scaleSkewCursorStyleHandler: ControlCursorCallback = (\n eventData,\n control,\n fabricObject,\n) => {\n return isAltAction(eventData, fabricObject)\n ? skewCursorStyleHandler(eventData, control, fabricObject)\n : scaleCursorStyleHandler(eventData, control, fabricObject);\n};\n/**\n * Composed action handler to either scale X or skew Y\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingXOrSkewingY: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerY(eventData, transform, x, y)\n : scalingX(eventData, transform, x, y);\n};\n\n/**\n * Composed action handler to either scale Y or skew X\n * Needs to be wrapped with `wrapWithFixedAnchor` to be effective\n * @param {Event} eventData javascript event that is doing the transform\n * @param {Object} transform javascript object containing a series of information around the current transform\n * @param {number} x current mouse x position, canvas normalized\n * @param {number} y current mouse y position, canvas normalized\n * @return {Boolean} true if some change happened\n */\nexport const scalingYOrSkewingX: TransformActionHandler = (\n eventData,\n transform,\n x,\n y,\n) => {\n return isAltAction(eventData, transform.target)\n ? skewHandlerX(eventData, transform, x, y)\n : scalingY(eventData, transform, x, y);\n};\n","import { RESIZING, ROTATE } from '../constants';\nimport { changeWidth } from './changeWidth';\nimport { Control } from './Control';\nimport { rotationStyleHandler, rotationWithSnapping } from './rotate';\nimport { scaleCursorStyleHandler, scalingEqually } from './scale';\nimport {\n scaleOrSkewActionName,\n scaleSkewCursorStyleHandler,\n scalingXOrSkewingY,\n scalingYOrSkewingX,\n} from './scaleSkew';\n\n// use this function if you want to generate new controls for every instance\nexport const createObjectDefaultControls = () => ({\n ml: new Control({\n x: -0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mr: new Control({\n x: 0.5,\n y: 0,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingXOrSkewingY,\n getActionName: scaleOrSkewActionName,\n }),\n\n mb: new Control({\n x: 0,\n y: 0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n mt: new Control({\n x: 0,\n y: -0.5,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionHandler: scalingYOrSkewingX,\n getActionName: scaleOrSkewActionName,\n }),\n\n tl: new Control({\n x: -0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n tr: new Control({\n x: 0.5,\n y: -0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n bl: new Control({\n x: -0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n br: new Control({\n x: 0.5,\n y: 0.5,\n cursorStyleHandler: scaleCursorStyleHandler,\n actionHandler: scalingEqually,\n }),\n\n mtr: new Control({\n x: 0,\n y: -0.5,\n actionHandler: rotationWithSnapping,\n cursorStyleHandler: rotationStyleHandler,\n offsetY: -40,\n withConnection: true,\n actionName: ROTATE,\n }),\n});\n\nexport const createResizeControls = () => ({\n mr: new Control({\n x: 0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n ml: new Control({\n x: -0.5,\n y: 0,\n actionHandler: changeWidth,\n cursorStyleHandler: scaleSkewCursorStyleHandler,\n actionName: RESIZING,\n }),\n});\n\nexport const createTextboxDefaultControls = () => ({\n ...createObjectDefaultControls(),\n ...createResizeControls(),\n});\n","import { Point, ZERO } from '../../Point';\nimport type { TCornerPoint, TDegree } from '../../typedefs';\nimport { FabricObject } from './Object';\nimport { degreesToRadians } from '../../util/misc/radiansDegreesConversion';\nimport type { TQrDecomposeOut } from '../../util/misc/matrix';\nimport {\n calcDimensionsMatrix,\n createRotateMatrix,\n createTranslateMatrix,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../../util/misc/matrix';\nimport type { Control } from '../../controls/Control';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport type { ObjectEvents, TPointerEvent } from '../../EventTypeDefs';\nimport type { Canvas } from '../../canvas/Canvas';\nimport type { ControlRenderingStyleOverride } from '../../controls/controlRendering';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { createObjectDefaultControls } from '../../controls/commonControls';\nimport { interactiveObjectDefaultValues } from './defaultValues';\nimport { SCALE } from '../../constants';\n\nexport type TOCoord = Point & {\n corner: TCornerPoint;\n touchCorner: TCornerPoint;\n};\n\nexport type TControlSet = Record;\n\nexport type TBorderRenderingStyleOverride = Partial<\n Pick\n>;\n\nexport type TStyleOverride = ControlRenderingStyleOverride &\n TBorderRenderingStyleOverride &\n Partial<\n Pick & {\n forActiveSelection: boolean;\n }\n >;\n\nexport class InteractiveFabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n declare noScaleCache: boolean;\n\n declare snapAngle?: TDegree;\n declare snapThreshold?: TDegree;\n\n declare lockMovementX: boolean;\n declare lockMovementY: boolean;\n declare lockRotation: boolean;\n declare lockScalingX: boolean;\n declare lockScalingY: boolean;\n declare lockSkewingX: boolean;\n declare lockSkewingY: boolean;\n declare lockScalingFlip: boolean;\n\n declare cornerSize: number;\n declare touchCornerSize: number;\n declare transparentCorners: boolean;\n declare cornerColor: string;\n declare cornerStrokeColor: string;\n declare cornerStyle: 'rect' | 'circle';\n declare cornerDashArray: number[] | null;\n declare hasControls: boolean;\n\n declare borderColor: string;\n declare borderDashArray: number[] | null;\n declare borderOpacityWhenMoving: number;\n declare borderScaleFactor: number;\n declare hasBorders: boolean;\n declare selectionBackgroundColor: string;\n\n declare selectable: boolean;\n declare evented: boolean;\n declare perPixelTargetFind: boolean;\n declare activeOn: 'down' | 'up';\n\n declare hoverCursor: CSSStyleDeclaration['cursor'] | null;\n declare moveCursor: CSSStyleDeclaration['cursor'] | null;\n\n /**\n * The object's controls' position in viewport coordinates\n * Calculated by {@link Control#positionHandler} and {@link Control#calcCornerCoords}, depending on {@link padding}.\n * `corner/touchCorner` describe the 4 points forming the interactive area of the corner.\n * Used to draw and locate controls.\n */\n declare oCoords: Record;\n\n /**\n * keeps the value of the last hovered corner during mouse move.\n * 0 is no corner, or 'mt', 'ml', 'mtr' etc..\n * It should be private, but there is no harm in using it as\n * a read-only property.\n * this isn't cleaned automatically. Non selected objects may have wrong values\n * @type [string]\n */\n declare __corner?: string;\n\n /**\n * a map of control visibility for this object.\n * this was left when controls were introduced to not break the api too much\n * this takes priority over the generic control visibility\n */\n declare _controlsVisibility: Record;\n\n /**\n * holds the controls for the object.\n * controls are added by default_controls.js\n */\n declare controls: TControlSet;\n\n /**\n * internal boolean to signal the code that the object is\n * part of the move action.\n */\n declare isMoving?: boolean;\n\n /**\n * A boolean used from the gesture module to keep tracking of a scaling\n * action when there is no scaling transform in place.\n * This is an edge case and is used twice in all codebase.\n * Probably added to keep track of some performance issues\n * @TODO use git blame to investigate why it was added\n * DON'T USE IT. WE WILL TRY TO REMOVE IT\n */\n declare _scaling?: boolean;\n\n declare canvas?: Canvas;\n\n static ownDefaults = interactiveObjectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...InteractiveFabricObject.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(\n this,\n (this.constructor as typeof InteractiveFabricObject).createControls(),\n InteractiveFabricObject.ownDefaults,\n );\n this.setOptions(options);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults\n * @param {Object} [options] Options object\n */\n static createControls(): { controls: Record } {\n return { controls: createObjectDefaultControls() };\n }\n\n /**\n * Update width and height of the canvas for cache\n * returns true or false if canvas needed resize.\n * @private\n * @return {Boolean} true if the canvas has been resized\n */\n _updateCacheCanvas() {\n const targetCanvas = this.canvas;\n if (this.noScaleCache && targetCanvas && targetCanvas._currentTransform) {\n const transform = targetCanvas._currentTransform,\n target = transform.target,\n action = transform.action;\n if (\n this === (target as unknown as this) &&\n action &&\n action.startsWith(SCALE)\n ) {\n return false;\n }\n }\n return super._updateCacheCanvas();\n }\n\n getActiveControl() {\n const key = this.__corner;\n return key\n ? {\n key,\n control: this.controls[key],\n coord: this.oCoords[key],\n }\n : undefined;\n }\n\n /**\n * Determines which corner is under the mouse cursor, represented by `pointer`.\n * This function is return a corner only if the object is the active one.\n * This is done to avoid selecting corner of non active object and activating transformations\n * rather than drag action. The default behavior of fabricJS is that if you want to transform\n * an object, first you select it to show the control set\n * @private\n * @param {Object} pointer The pointer indicating the mouse position\n * @param {boolean} forTouch indicates if we are looking for interaction area with a touch action\n * @return {String|Boolean} corner code (tl, tr, bl, br, etc.), or 0 if nothing is found.\n */\n findControl(\n pointer: Point,\n forTouch = false,\n ): { key: string; control: Control; coord: TOCoord } | undefined {\n if (!this.hasControls || !this.canvas) {\n return undefined;\n }\n\n this.__corner = undefined;\n const cornerEntries = Object.entries(this.oCoords);\n for (let i = cornerEntries.length - 1; i >= 0; i--) {\n const [key, corner] = cornerEntries[i];\n const control = this.controls[key];\n\n if (\n control.shouldActivate(\n key,\n this,\n pointer,\n forTouch ? corner.touchCorner : corner.corner,\n )\n ) {\n // this.canvas.contextTop.fillRect(pointer.x - 1, pointer.y - 1, 2, 2);\n this.__corner = key;\n\n return { key, control, coord: this.oCoords[key] };\n }\n }\n\n return undefined;\n }\n\n /**\n * Calculates the coordinates of the center of each control plus the corners of the control itself\n * This basically just delegates to each control positionHandler\n * WARNING: changing what is passed to positionHandler is a breaking change, since position handler\n * is a public api and should be done just if extremely necessary\n * @return {Record}\n */\n calcOCoords(): Record {\n const vpt = this.getViewportTransform(),\n center = this.getCenterPoint(),\n tMatrix = createTranslateMatrix(center.x, center.y),\n rMatrix = createRotateMatrix({\n angle: this.getTotalAngle() - (!!this.group && this.flipX ? 180 : 0),\n }),\n positionMatrix = multiplyTransformMatrices(tMatrix, rMatrix),\n startMatrix = multiplyTransformMatrices(vpt, positionMatrix),\n finalMatrix = multiplyTransformMatrices(startMatrix, [\n 1 / vpt[0],\n 0,\n 0,\n 1 / vpt[3],\n 0,\n 0,\n ]),\n transformOptions = this.group\n ? qrDecompose(this.calcTransformMatrix())\n : undefined;\n // decomposing could bring negative scaling and `_calculateCurrentDimensions` can't take it\n if (transformOptions) {\n transformOptions.scaleX = Math.abs(transformOptions.scaleX);\n transformOptions.scaleY = Math.abs(transformOptions.scaleY);\n }\n const dim = this._calculateCurrentDimensions(transformOptions),\n coords: Record = {};\n\n this.forEachControl((control, key) => {\n const position = control.positionHandler(dim, finalMatrix, this, control);\n // coords[key] are sometimes used as points. Those are points to which we add\n // the property corner and touchCorner from `_calcCornerCoords`.\n // don't remove this assign for an object spread.\n coords[key] = Object.assign(\n position,\n this._calcCornerCoords(control, position),\n );\n });\n\n // debug code\n /*\n const canvas = this.canvas;\n setTimeout(function () {\n if (!canvas) return;\n canvas.contextTop.clearRect(0, 0, 700, 700);\n canvas.contextTop.fillStyle = 'green';\n Object.keys(coords).forEach(function(key) {\n const control = coords[key];\n canvas.contextTop.fillRect(control.x, control.y, 3, 3);\n });\n } 50);\n */\n return coords;\n }\n\n /**\n * Sets the coordinates that determine the interaction area of each control\n * note: if we would switch to ROUND corner area, all of this would disappear.\n * everything would resolve to a single point and a pythagorean theorem for the distance\n * @todo evaluate simplification of code switching to circle interaction area at runtime\n * @private\n */\n private _calcCornerCoords(control: Control, position: Point) {\n const angle = this.getTotalAngle();\n const corner = control.calcCornerCoords(\n angle,\n this.cornerSize,\n position.x,\n position.y,\n false,\n this,\n );\n const touchCorner = control.calcCornerCoords(\n angle,\n this.touchCornerSize,\n position.x,\n position.y,\n true,\n this,\n );\n return { corner, touchCorner };\n }\n\n /**\n * @override set controls' coordinates as well\n * See {@link https://github.com/fabricjs/fabric.js/wiki/When-to-call-setCoords} and {@link http://fabricjs.com/fabric-gotchas}\n * @return {void}\n */\n setCoords(): void {\n super.setCoords();\n this.canvas && (this.oCoords = this.calcOCoords());\n }\n\n /**\n * Calls a function for each control. The function gets called,\n * with the control, the control's key and the object that is calling the iterator\n * @param {Function} fn function to iterate over the controls over\n */\n forEachControl(\n fn: (\n control: Control,\n key: string,\n fabricObject: InteractiveFabricObject,\n ) => any,\n ) {\n for (const i in this.controls) {\n fn(this.controls[i], i, this);\n }\n }\n\n /**\n * Draws a colored layer behind the object, inside its selection borders.\n * Requires public options: padding, selectionBackgroundColor\n * this function is called when the context is transformed\n * has checks to be skipped when the object is on a staticCanvas\n * @todo evaluate if make this disappear in favor of a pre-render hook for objects\n * this was added by Andrea Bogazzi to make possible some feature for work reasons\n * it seemed a good option, now is an edge case\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n */\n drawSelectionBackground(ctx: CanvasRenderingContext2D): void {\n if (\n !this.selectionBackgroundColor ||\n (this.canvas && (this.canvas._activeObject as unknown as this) !== this)\n ) {\n return;\n }\n ctx.save();\n const center = this.getRelativeCenterPoint(),\n wh = this._calculateCurrentDimensions(),\n vpt = this.getViewportTransform();\n ctx.translate(center.x, center.y);\n ctx.scale(1 / vpt[0], 1 / vpt[3]);\n ctx.rotate(degreesToRadians(this.angle));\n ctx.fillStyle = this.selectionBackgroundColor;\n ctx.fillRect(-wh.x / 2, -wh.y / 2, wh.x, wh.y);\n ctx.restore();\n }\n\n /**\n * @public override this function in order to customize the drawing of the control box, e.g. rounded corners, different border style.\n * @param {CanvasRenderingContext2D} ctx ctx is rotated and translated so that (0,0) is at object's center\n * @param {Point} size the control box size used\n */\n strokeBorders(ctx: CanvasRenderingContext2D, size: Point): void {\n ctx.strokeRect(-size.x / 2, -size.y / 2, size.x, size.y);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size\n * @param {TStyleOverride} styleOverride object to override the object style\n */\n _drawBorders(\n ctx: CanvasRenderingContext2D,\n size: Point,\n styleOverride: TStyleOverride = {},\n ): void {\n const options = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n borderDashArray: this.borderDashArray,\n ...styleOverride,\n };\n ctx.save();\n ctx.strokeStyle = options.borderColor;\n this._setLineDash(ctx, options.borderDashArray);\n this.strokeBorders(ctx, size);\n options.hasControls && this.drawControlsConnectingLines(ctx, size);\n ctx.restore();\n }\n\n /**\n * Renders controls and borders for the object\n * the context here is not transformed\n * @todo move to interactivity\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {TStyleOverride} [styleOverride] properties to override the object style\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: TStyleOverride = {},\n ) {\n const { hasBorders, hasControls } = this;\n const styleOptions = {\n hasBorders,\n hasControls,\n ...styleOverride,\n };\n const vpt = this.getViewportTransform(),\n shouldDrawBorders = styleOptions.hasBorders,\n shouldDrawControls = styleOptions.hasControls;\n const matrix = multiplyTransformMatrices(vpt, this.calcTransformMatrix());\n const options = qrDecompose(matrix);\n ctx.save();\n ctx.translate(options.translateX, options.translateY);\n ctx.lineWidth = this.borderScaleFactor; // 1 * this.borderScaleFactor;\n // since interactive groups have been introduced, an object could be inside a group and needing controls\n // the following equality check `this.group === this.parent` covers:\n // object without a group ( undefined === undefined )\n // object inside a group\n // excludes object inside a group but multi selected since group and parent will differ in value\n if (this.group === this.parent) {\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n }\n if (this.flipX) {\n options.angle -= 180;\n }\n ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));\n shouldDrawBorders && this.drawBorders(ctx, options, styleOverride);\n shouldDrawControls && this.drawControls(ctx, styleOverride);\n ctx.restore();\n }\n\n /**\n * Draws borders of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {object} options object representing current object parameters\n * @param {TStyleOverride} [styleOverride] object to override the object style\n */\n drawBorders(\n ctx: CanvasRenderingContext2D,\n options: TQrDecomposeOut,\n styleOverride: TStyleOverride,\n ): void {\n let size;\n if ((styleOverride && styleOverride.forActiveSelection) || this.group) {\n const bbox = sizeAfterTransform(\n this.width,\n this.height,\n calcDimensionsMatrix(options),\n ),\n stroke = !this.isStrokeAccountedForInDimensions()\n ? (this.strokeUniform\n ? new Point().scalarAdd(this.canvas ? this.canvas.getZoom() : 1)\n : // this is extremely confusing. options comes from the upper function\n // and is the qrDecompose of a matrix that takes in account zoom too\n new Point(options.scaleX, options.scaleY)\n ).scalarMultiply(this.strokeWidth)\n : ZERO;\n size = bbox\n .add(stroke)\n .scalarAdd(this.borderScaleFactor)\n .scalarAdd(this.padding * 2);\n } else {\n size = this._calculateCurrentDimensions().scalarAdd(\n this.borderScaleFactor,\n );\n }\n this._drawBorders(ctx, size, styleOverride);\n }\n\n /**\n * Draws lines from a borders of an object's bounding box to controls that have `withConnection` property set.\n * Requires public properties: width, height\n * Requires public options: padding, borderColor\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {Point} size object size x = width, y = height\n */\n drawControlsConnectingLines(\n ctx: CanvasRenderingContext2D,\n size: Point,\n ): void {\n let shouldStroke = false;\n\n ctx.beginPath();\n this.forEachControl((control, key) => {\n // in this moment, the ctx is centered on the object.\n // width and height of the above function are the size of the bbox.\n if (control.withConnection && control.getVisibility(this, key)) {\n // reset movement for each control\n shouldStroke = true;\n ctx.moveTo(control.x * size.x, control.y * size.y);\n ctx.lineTo(\n control.x * size.x + control.offsetX,\n control.y * size.y + control.offsetY,\n );\n }\n });\n shouldStroke && ctx.stroke();\n }\n\n /**\n * Draws corners of an object's bounding box.\n * Requires public properties: width, height\n * Requires public options: cornerSize, padding\n * Be aware that since fabric 6.0 this function does not call setCoords anymore.\n * setCoords needs to be called manually if the object of which we are rendering controls\n * is outside the standard selection and transform process.\n * @param {CanvasRenderingContext2D} ctx Context to draw on\n * @param {ControlRenderingStyleOverride} styleOverride object to override the object style\n */\n drawControls(\n ctx: CanvasRenderingContext2D,\n styleOverride: ControlRenderingStyleOverride = {},\n ) {\n ctx.save();\n const retinaScaling = this.getCanvasRetinaScaling();\n const { cornerStrokeColor, cornerDashArray, cornerColor } = this;\n const options = {\n cornerStrokeColor,\n cornerDashArray,\n cornerColor,\n ...styleOverride,\n };\n ctx.setTransform(retinaScaling, 0, 0, retinaScaling, 0, 0);\n ctx.strokeStyle = ctx.fillStyle = options.cornerColor;\n if (!this.transparentCorners) {\n ctx.strokeStyle = options.cornerStrokeColor;\n }\n this._setLineDash(ctx, options.cornerDashArray);\n this.forEachControl((control, key) => {\n if (control.getVisibility(this, key)) {\n const p = this.oCoords[key];\n control.render(ctx, p.x, p.y, options, this);\n }\n });\n ctx.restore();\n }\n\n /**\n * Returns true if the specified control is visible, false otherwise.\n * @param {string} controlKey The key of the control. Possible values are usually 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr',\n * but since the control api allow for any control name, can be any string.\n * @returns {boolean} true if the specified control is visible, false otherwise\n */\n isControlVisible(controlKey: string): boolean {\n return (\n this.controls[controlKey] &&\n this.controls[controlKey].getVisibility(this, controlKey)\n );\n }\n\n /**\n * Sets the visibility of the specified control.\n * please do not use.\n * @param {String} controlKey The key of the control. Possible values are 'tl', 'tr', 'br', 'bl', 'ml', 'mt', 'mr', 'mb', 'mtr'.\n * but since the control api allow for any control name, can be any string.\n * @param {Boolean} visible true to set the specified control visible, false otherwise\n * @todo discuss this overlap of priority here with the team. Andrea Bogazzi for details\n */\n setControlVisible(controlKey: string, visible: boolean) {\n if (!this._controlsVisibility) {\n this._controlsVisibility = {};\n }\n this._controlsVisibility[controlKey] = visible;\n }\n\n /**\n * Sets the visibility state of object controls, this is just a bulk option for setControlVisible;\n * @param {Record} [options] with an optional key per control\n * example: {Boolean} [options.bl] true to enable the bottom-left control, false to disable it\n */\n setControlsVisibility(options: Record = {}) {\n Object.entries(options).forEach(([controlKey, visibility]) =>\n this.setControlVisible(controlKey, visibility),\n );\n }\n\n /**\n * Clears the canvas.contextTop in a specific area that corresponds to the object's bounding box\n * that is in the canvas.contextContainer.\n * This function is used to clear pieces of contextTop where we render ephemeral effects on top of the object.\n * Example: blinking cursor text selection, drag effects.\n * @todo discuss swapping restoreManually with a renderCallback, but think of async issues\n * @param {Boolean} [restoreManually] When true won't restore the context after clear, in order to draw something else.\n * @return {CanvasRenderingContext2D|undefined} canvas.contextTop that is either still transformed\n * with the object transformMatrix, or restored to neutral transform\n */\n clearContextTop(\n restoreManually?: boolean,\n ): CanvasRenderingContext2D | undefined {\n if (!this.canvas) {\n return;\n }\n const ctx = this.canvas.contextTop;\n if (!ctx) {\n return;\n }\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n this.transform(ctx);\n // we add 4 pixel, to be sure to do not leave any pixel out\n const width = this.width + 4,\n height = this.height + 4;\n ctx.clearRect(-width / 2, -height / 2, width, height);\n\n restoreManually || ctx.restore();\n return ctx;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to deselect this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {TPointerEvent} [options.e] event if the process is generated by an event\n * @param {FabricObject} [options.object] next object we are setting as active, and reason why\n * this is being deselected\n */\n onDeselect(_options?: {\n e?: TPointerEvent;\n object?: InteractiveFabricObject;\n }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * This callback function is called every time _discardActiveObject or _setActiveObject\n * try to to select this object. If the function returns true, the process is cancelled\n * @param {Object} [_options] options sent from the upper functions\n * @param {Event} [_options.e] event if the process is generated by an event\n */\n onSelect(_options?: { e?: TPointerEvent }): boolean {\n // implemented by sub-classes, as needed.\n return false;\n }\n\n /**\n * Override to customize Drag behavior\n * Fired from {@link Canvas#_onMouseMove}\n * @returns true in order for the window to start a drag session\n */\n shouldStartDragging(_e: TPointerEvent) {\n return false;\n }\n\n /**\n * Override to customize Drag behavior\\\n * Fired once a drag session has started\n * @returns true to handle the drag event\n */\n onDragStart(_e: DragEvent) {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * @public\n * @param {DragEvent} _e\n * @returns {boolean} true if the object currently dragged can be dropped on the target\n */\n canDrop(_e: DragEvent): boolean {\n return false;\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the source of a drag event\n * example: render the selection status for the part of text that is being dragged from a text object\n * @public\n * @param {DragEvent} _e\n */\n renderDragSourceEffect(_e: DragEvent) {\n // for subclasses\n }\n\n /**\n * Override to customize drag and drop behavior\n * render a specific effect when an object is the target of a drag event\n * used to show that the underly object can receive a drop, or to show how the\n * object will change when dropping. example: show the cursor where the text is about to be dropped\n * @public\n * @param {DragEvent} _e\n */\n renderDropTargetEffect(_e: DragEvent) {\n // for subclasses\n }\n}\n","import type { Constructor } from '../typedefs';\n\n/***\n * https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern\n */\nexport function applyMixins(\n derivedCtor: T,\n constructors: S[],\n) {\n constructors.forEach((baseCtor) => {\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n name !== 'constructor' &&\n Object.defineProperty(\n derivedCtor.prototype,\n name,\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n return derivedCtor as T & { prototype: InstanceType };\n}\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport { FabricObjectSVGExportMixin } from './FabricObjectSVGExportMixin';\nimport { InteractiveFabricObject } from './InteractiveObject';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps } from './types/FabricObjectProps';\nimport type { TFabricObjectProps, SerializedObjectProps } from './types';\nimport { classRegistry } from '../../ClassRegistry';\n\n// TODO somehow we have to make a tree-shakeable import\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface FabricObject<\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n Props extends TFabricObjectProps = Partial,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n SProps extends SerializedObjectProps = SerializedObjectProps,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObjectSVGExportMixin {}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging\nexport class FabricObject<\n Props extends TFabricObjectProps = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends InteractiveFabricObject {}\n\napplyMixins(FabricObject, [FabricObjectSVGExportMixin]);\n\nclassRegistry.setClass(FabricObject);\nclassRegistry.setClass(FabricObject, 'object');\n\nexport { cacheProperties } from './defaultValues';\n","/**\n * Returns true if context has transparent pixel\n * at specified location (taking tolerance into account)\n * @param {CanvasRenderingContext2D} ctx context\n * @param {Number} x x coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} y y coordinate in canvasElementCoordinate, not fabric space. integer\n * @param {Number} tolerance Tolerance pixels around the point, not alpha tolerance, integer\n * @return {boolean} true if transparent\n */\nexport const isTransparent = (\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n tolerance: number,\n): boolean => {\n tolerance = Math.round(tolerance);\n const size = tolerance * 2 + 1;\n const { data } = ctx.getImageData(x - tolerance, y - tolerance, size, size);\n\n // Split image data - for tolerance > 1, pixelDataSize = 4;\n for (let i = 3; i < data.length; i += 4) {\n const alphaChannel = data[i];\n if (alphaChannel > 0) {\n return false;\n }\n }\n return true;\n};\n","import type { Point } from '../../Point';\nimport type { TRadian } from '../../typedefs';\n/**\n * Rotates `point` around `origin` with `radians`\n * @deprecated use the Point.rotate\n * @param {Point} origin The origin of the rotation\n * @param {Point} origin The origin of the rotation\n * @param {TRadian} radians The radians of the angle for the rotation\n * @return {Point} The new rotated point\n */\nexport const rotatePoint = (\n point: Point,\n origin: Point,\n radians: TRadian,\n): Point => point.rotate(radians, origin);\n","export const findIndexRight = (\n array: T[],\n predicate: (value: T, index: number, array: T[]) => boolean,\n) => {\n for (let index = array.length - 1; index >= 0; index--) {\n if (predicate(array[index], index, array)) {\n return index;\n }\n }\n return -1;\n};\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport { createVector } from '../vectors';\nimport type { TProjectStrokeOnPointsOptions, TProjection } from './types';\n\n/**\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n * @todo consider removing skewing from points before calculating stroke projection,\n * see https://github.com/fabricjs/fabric.js/commit/494a10ee2f8c2278ae9a55b20bf50cf6ee25b064#commitcomment-94751537\n */\nexport abstract class StrokeProjectionsBase {\n declare options: TProjectStrokeOnPointsOptions;\n declare scale: Point;\n declare strokeUniformScalar: Point;\n declare strokeProjectionMagnitude: number;\n\n constructor(options: TProjectStrokeOnPointsOptions) {\n this.options = options;\n this.strokeProjectionMagnitude = this.options.strokeWidth / 2;\n this.scale = new Point(this.options.scaleX, this.options.scaleY);\n this.strokeUniformScalar = this.options.strokeUniform\n ? new Point(1 / this.options.scaleX, 1 / this.options.scaleY)\n : new Point(1, 1);\n }\n\n /**\n * When the stroke is uniform, scaling affects the arrangement of points. So we must take it into account.\n */\n protected createSideVector(from: XY, to: XY) {\n const v = createVector(from, to);\n return this.options.strokeUniform ? v.multiply(this.scale) : v;\n }\n\n protected abstract calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude?: number,\n ): Point;\n\n protected projectOrthogonally(from: Point, to: Point, magnitude?: number) {\n return this.applySkew(\n from.add(this.calcOrthogonalProjection(from, to, magnitude)),\n );\n }\n\n protected isSkewed() {\n return this.options.skewX !== 0 || this.options.skewY !== 0;\n }\n\n protected applySkew(point: Point) {\n const p = new Point(point);\n // skewY must be applied before skewX as this distortion affects skewX calculation\n p.y += p.x * Math.tan(degreesToRadians(this.options.skewY));\n p.x += p.y * Math.tan(degreesToRadians(this.options.skewX));\n return p;\n }\n\n protected scaleUnitVector(unitVector: Point, scalar: number) {\n return unitVector.multiply(this.strokeUniformScalar).scalarMultiply(scalar);\n }\n\n protected abstract projectPoints(): Point[];\n\n public abstract project(): TProjection[];\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { halfPI, twoMathPi } from '../../../constants';\nimport type { TRadian } from '../../../typedefs';\nimport { degreesToRadians } from '../radiansDegreesConversion';\nimport {\n calcAngleBetweenVectors,\n calcVectorRotation,\n crossProduct,\n getOrthonormalVector,\n getUnitVector,\n isBetweenVectors,\n magnitude,\n rotateVector,\n} from '../vectors';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nconst zeroVector = new Point();\n\n/**\n * class in charge of finding projections for each type of line join\n * @see {@link [Closed path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#2-closed-path)}\n *\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin\n * - Spec: https://svgwg.org/svg2-draft/painting.html#StrokeLinejoinProperty\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n *\n */\nexport class StrokeLineJoinProjections extends StrokeProjectionsBase {\n /**\n * The point being projected (the angle ∠BAC)\n */\n declare A: Point;\n /**\n * The point before A\n */\n declare B: Point;\n /**\n * The point after A\n */\n declare C: Point;\n /**\n * The AB vector\n */\n AB: Point;\n /**\n * The AC vector\n */\n AC: Point;\n /**\n * The angle of A (∠BAC)\n */\n alpha: TRadian;\n /**\n * The bisector of A (∠BAC)\n */\n bisector: Point;\n\n static getOrthogonalRotationFactor(vector1: Point, vector2?: Point) {\n const angle = vector2\n ? calcAngleBetweenVectors(vector1, vector2)\n : calcVectorRotation(vector1);\n return Math.abs(angle) < halfPI ? -1 : 1;\n }\n\n constructor(A: XY, B: XY, C: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.B = new Point(B);\n this.C = new Point(C);\n this.AB = this.createSideVector(this.A, this.B);\n this.AC = this.createSideVector(this.A, this.C);\n this.alpha = calcAngleBetweenVectors(this.AB, this.AC);\n this.bisector = getUnitVector(\n // if AC is also the zero vector nothing will be projected\n // in that case the next point will handle the projection\n rotateVector(this.AB.eq(zeroVector) ? this.AC : this.AB, this.alpha / 2),\n );\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n const orthogonalProjection = getOrthonormalVector(vector);\n const correctSide = StrokeLineJoinProjections.getOrthogonalRotationFactor(\n orthogonalProjection,\n this.bisector,\n );\n return this.scaleUnitVector(orthogonalProjection, magnitude * correctSide);\n }\n\n /**\n * BEVEL\n * Calculation: the projection points are formed by the vector orthogonal to the vertex.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-2-bevel\n */\n projectBevel() {\n const projections: Point[] = [];\n // if `alpha` equals 0 or 2*PI, the projections are the same for `B` and `C`\n (this.alpha % twoMathPi === 0 ? [this.B] : [this.B, this.C]).forEach(\n (to) => {\n projections.push(this.projectOrthogonally(this.A, to));\n projections.push(\n this.projectOrthogonally(this.A, to, -this.strokeProjectionMagnitude),\n );\n },\n );\n return projections;\n }\n\n /**\n * MITER\n * Calculation: the corner is formed by extending the outer edges of the stroke\n * at the tangents of the path segments until they intersect.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-1-miter\n */\n projectMiter() {\n const projections: Point[] = [],\n alpha = Math.abs(this.alpha),\n hypotUnitScalar = 1 / Math.sin(alpha / 2),\n miterVector = this.scaleUnitVector(\n this.bisector,\n -this.strokeProjectionMagnitude * hypotUnitScalar,\n );\n\n // When two line segments meet at a sharp angle, it is possible for the join to extend,\n // far beyond the thickness of the line stroking the path. The stroke-miterlimit imposes\n // a limit on the extent of the line join.\n // MDN: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit\n // When the stroke is uniform, scaling changes the arrangement of points, this changes the miter-limit\n const strokeMiterLimit = this.options.strokeUniform\n ? magnitude(\n this.scaleUnitVector(this.bisector, this.options.strokeMiterLimit),\n )\n : this.options.strokeMiterLimit;\n\n if (\n magnitude(miterVector) / this.strokeProjectionMagnitude <=\n strokeMiterLimit\n ) {\n projections.push(this.applySkew(this.A.add(miterVector)));\n }\n /* when the miter-limit is reached, the stroke line join becomes of type bevel.\n We always need two orthogonal projections which are basically bevel-type projections,\n so regardless of whether the miter-limit was reached or not, we include these projections.\n */\n projections.push(...this.projectBevel());\n\n return projections;\n }\n\n /**\n * ROUND (without skew)\n * Calculation: the projections are the two vectors parallel to X and Y axes\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-1-round-without-skew\n */\n private projectRoundNoSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [],\n // correctSide is used to only consider projecting for the outer side\n correctSide = new Point(\n StrokeLineJoinProjections.getOrthogonalRotationFactor(this.bisector),\n StrokeLineJoinProjections.getOrthogonalRotationFactor(\n new Point(this.bisector.y, this.bisector.x),\n ),\n ),\n radiusOnAxisX = new Point(1, 0)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide),\n radiusOnAxisY = new Point(0, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar)\n .multiply(correctSide);\n\n [radiusOnAxisX, radiusOnAxisY].forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.A.add(vector));\n }\n });\n return projections;\n }\n\n /**\n * ROUND (with skew)\n * Calculation: the projections are the points furthest from the vertex in\n * the direction of the X and Y axes after distortion.\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#2-3-2-round-skew\n */\n private projectRoundWithSkew(startCircle: Point, endCircle: Point) {\n const projections: Point[] = [];\n\n const { skewX, skewY, scaleX, scaleY, strokeUniform } = this.options,\n shearing = new Point(\n Math.tan(degreesToRadians(skewX)),\n Math.tan(degreesToRadians(skewY)),\n );\n // The points furthest from the vertex in the direction of the X and Y axes after distortion\n const circleRadius = this.strokeProjectionMagnitude,\n newY = strokeUniform\n ? circleRadius /\n scaleY /\n Math.sqrt(1 / scaleY ** 2 + (1 / scaleX ** 2) * shearing.y ** 2)\n : circleRadius / Math.sqrt(1 + shearing.y ** 2),\n furthestY = new Point(\n // Safe guard due to floating point precision. In some situations the square root\n // was returning NaN because of a negative number close to zero.\n Math.sqrt(Math.max(circleRadius ** 2 - newY ** 2, 0)),\n newY,\n ),\n newX = strokeUniform\n ? circleRadius /\n Math.sqrt(\n 1 +\n (shearing.x ** 2 * (1 / scaleY) ** 2) /\n (1 / scaleX + (1 / scaleX) * shearing.x * shearing.y) ** 2,\n )\n : circleRadius /\n Math.sqrt(1 + shearing.x ** 2 / (1 + shearing.x * shearing.y) ** 2),\n furthestX = new Point(\n newX,\n Math.sqrt(Math.max(circleRadius ** 2 - newX ** 2, 0)),\n );\n\n [\n furthestX,\n furthestX.scalarMultiply(-1),\n furthestY,\n furthestY.scalarMultiply(-1),\n ]\n // We need to skew the vector here as this information is used to check if\n // it is between the start and end of the circle segment\n .map((vector) =>\n this.applySkew(\n strokeUniform ? vector.multiply(this.strokeUniformScalar) : vector,\n ),\n )\n .forEach((vector) => {\n if (isBetweenVectors(vector, startCircle, endCircle)) {\n projections.push(this.applySkew(this.A).add(vector));\n }\n });\n\n return projections;\n }\n\n projectRound() {\n const projections: Point[] = [];\n /* Include the start and end points of the circle segment, so that only\n the projections contained within it are included */\n // add the orthogonal projections (start and end points of circle segment)\n projections.push(...this.projectBevel());\n // let's determines which one of the orthogonal projection is the beginning and end of the circle segment.\n // when `alpha` equals 0 or 2*PI, we have a straight line, so the way to find the start/end is different.\n const isStraightLine = this.alpha % twoMathPi === 0,\n // change the origin of the projections to point A\n // so that the cross product calculation is correct\n newOrigin = this.applySkew(this.A),\n proj0 = projections[isStraightLine ? 0 : 2].subtract(newOrigin),\n proj1 = projections[isStraightLine ? 1 : 0].subtract(newOrigin),\n // when `isStraightLine` === true, we compare with the vector opposite AB, otherwise we compare with the bisector.\n comparisonVector = isStraightLine\n ? this.applySkew(this.AB.scalarMultiply(-1))\n : this.applySkew(\n this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1),\n ),\n // the beginning of the circle segment is always to the right of the comparison vector (cross product > 0)\n isProj0Start = crossProduct(proj0, comparisonVector) > 0,\n startCircle = isProj0Start ? proj0 : proj1,\n endCircle = isProj0Start ? proj1 : proj0;\n if (!this.isSkewed()) {\n projections.push(...this.projectRoundNoSkew(startCircle, endCircle));\n } else {\n projections.push(...this.projectRoundWithSkew(startCircle, endCircle));\n }\n return projections;\n }\n\n /**\n * Project stroke width on points returning projections for each point as follows:\n * - `miter`: 1 point corresponding to the outer boundary. If the miter limit is exceeded, it will be 2 points (becomes bevel)\n * - `bevel`: 2 points corresponding to the bevel possible boundaries, orthogonal to the stroke.\n * - `round`: same as `bevel` when it has no skew, with skew are 4 points.\n */\n protected projectPoints() {\n switch (this.options.strokeLineJoin) {\n case 'miter':\n return this.projectMiter();\n case 'round':\n return this.projectRound();\n default:\n return this.projectBevel();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n angle: this.alpha,\n bisector: this.bisector,\n }));\n }\n}\n","import type { XY } from '../../../Point';\nimport { Point } from '../../../Point';\nimport { getOrthonormalVector, getUnitVector } from '../vectors';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport { StrokeProjectionsBase } from './StrokeProjectionsBase';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\n/**\n * class in charge of finding projections for each type of line cap for start/end of an open path\n * @see {@link [Open path projections at #8344](https://github.com/fabricjs/fabric.js/pull/8344#1-open-path)}\n *\n * Reference:\n * - MDN:\n * - https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap\n * - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap\n * - Spec: https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap-dev\n * - Playground to understand how the line joins works: https://hypertolosana.github.io/efficient-webgl-stroking/index.html\n * - View the calculated projections for each of the control points: https://codesandbox.io/s/project-stroke-points-with-context-to-trace-b8jc4j?file=/src/index.js\n */\nexport class StrokeLineCapProjections extends StrokeProjectionsBase {\n /**\n * edge point\n */\n declare A: Point;\n /**\n * point next to edge point\n */\n declare T: Point;\n\n constructor(A: XY, T: XY, options: TProjectStrokeOnPointsOptions) {\n super(options);\n this.A = new Point(A);\n this.T = new Point(T);\n }\n\n calcOrthogonalProjection(\n from: Point,\n to: Point,\n magnitude: number = this.strokeProjectionMagnitude,\n ) {\n const vector = this.createSideVector(from, to);\n return this.scaleUnitVector(getOrthonormalVector(vector), magnitude);\n }\n\n /**\n * OPEN PATH START/END - Line cap: Butt\n * Calculation: to find the projections, just find the points orthogonal to the stroke\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-1-butt\n */\n projectButt() {\n return [\n this.projectOrthogonally(this.A, this.T, this.strokeProjectionMagnitude),\n this.projectOrthogonally(this.A, this.T, -this.strokeProjectionMagnitude),\n ];\n }\n\n /**\n * OPEN PATH START/END - Line cap: Round\n * Calculation: same as stroke line join `round`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-2-round\n */\n projectRound() {\n const projections: Point[] = [];\n\n if (!this.isSkewed() && this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(\n this.applySkew(this.A.add(projection)),\n this.applySkew(this.A.subtract(projection)),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(\n this.A,\n this.T,\n this.T,\n this.options,\n ).projectRound(),\n );\n }\n\n return projections;\n }\n\n /**\n * OPEN PATH START/END - Line cap: Square\n * Calculation: project a rectangle of points on the stroke in the opposite direction of the vector `AT`\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344#1-3-square\n */\n projectSquare() {\n const projections: Point[] = [];\n\n if (this.A.eq(this.T)) {\n /* 1 point case without `skew`\n When `strokeUniform` is true, scaling has no effect.\n So we divide by scale, to remove its effect.\n */\n const projection = new Point(1, 1)\n .scalarMultiply(this.strokeProjectionMagnitude)\n .multiply(this.strokeUniformScalar);\n projections.push(this.A.add(projection), this.A.subtract(projection));\n } else {\n const orthogonalProjection = this.calcOrthogonalProjection(\n this.A,\n this.T,\n this.strokeProjectionMagnitude,\n );\n const strokePointingOut = this.scaleUnitVector(\n getUnitVector(this.createSideVector(this.A, this.T)),\n -this.strokeProjectionMagnitude,\n );\n const projectedA = this.A.add(strokePointingOut);\n projections.push(\n projectedA.add(orthogonalProjection),\n projectedA.subtract(orthogonalProjection),\n );\n }\n\n return projections.map((p) => this.applySkew(p));\n }\n\n protected projectPoints() {\n switch (this.options.strokeLineCap) {\n case 'round':\n return this.projectRound();\n case 'square':\n return this.projectSquare();\n default:\n return this.projectButt();\n }\n }\n\n public project(): TProjection[] {\n return this.projectPoints().map((point) => ({\n originPoint: this.A,\n projectedPoint: point,\n }));\n }\n}\n","import { Point, type XY } from '../../../Point';\nimport { findIndexRight } from '../../internals/findRight';\nimport { StrokeLineCapProjections } from './StrokeLineCapProjections';\nimport { StrokeLineJoinProjections } from './StrokeLineJoinProjections';\nimport type { TProjection, TProjectStrokeOnPointsOptions } from './types';\n\nexport * from './types';\n\n/**\n *\n * Used to calculate object's bounding box\n *\n * @see https://github.com/fabricjs/fabric.js/pull/8344\n *\n */\nexport const projectStrokeOnPoints = (\n points: XY[],\n options: TProjectStrokeOnPointsOptions,\n openPath = false,\n): TProjection[] => {\n const projections: TProjection[] = [];\n\n if (points.length === 0) {\n return projections;\n }\n\n // first we remove duplicate neighboring points\n const reduced = points.reduce(\n (reduced, point) => {\n if (!reduced[reduced.length - 1].eq(point)) {\n reduced.push(new Point(point));\n }\n return reduced;\n },\n [new Point(points[0])],\n );\n\n if (reduced.length === 1) {\n openPath = true;\n } else if (!openPath) {\n // remove points from end in case they equal the first point\n // in order to correctly project the first point\n const start = reduced[0];\n const index = findIndexRight(reduced, (point) => !point.eq(start));\n reduced.splice(index + 1);\n }\n\n reduced.forEach((A, index, points) => {\n let B: XY, C: XY;\n if (index === 0) {\n C = points[1];\n B = openPath ? A : points[points.length - 1];\n } else if (index === points.length - 1) {\n B = points[index - 1];\n C = openPath ? A : points[0];\n } else {\n B = points[index - 1];\n C = points[index + 1];\n }\n\n if (openPath && points.length === 1) {\n projections.push(\n ...new StrokeLineCapProjections(A, A, options).project(),\n );\n } else if (openPath && (index === 0 || index === points.length - 1)) {\n projections.push(\n ...new StrokeLineCapProjections(\n A,\n index === 0 ? C : B,\n options,\n ).project(),\n );\n } else {\n projections.push(\n ...new StrokeLineJoinProjections(A, B, C, options).project(),\n );\n }\n });\n\n return projections;\n};\n","import type { TextStyle } from '../../shapes/Text/StyledText';\n\nexport const cloneStyles = (style: TextStyle): TextStyle => {\n const newObj: TextStyle = {};\n Object.keys(style).forEach((key) => {\n newObj[key] = {};\n Object.keys(style[key]).forEach((keyInner) => {\n newObj[key][keyInner] = { ...style[key][keyInner] };\n });\n });\n return newObj;\n};\n","/**\n * Capitalizes a string\n * @param {String} string String to capitalize\n * @param {Boolean} [firstLetterOnly] If true only first letter is capitalized\n * and other letters stay untouched, if false first letter is capitalized\n * and other letters are converted to lowercase.\n * @return {String} Capitalized version of a string\n */\nexport const capitalize = (string: string, firstLetterOnly = false): string =>\n `${string.charAt(0).toUpperCase()}${\n firstLetterOnly ? string.slice(1) : string.slice(1).toLowerCase()\n }`;\n\n/**\n * Escapes XML in a string\n * @param {String} string String to escape\n * @return {String} Escaped version of a string\n */\nexport const escapeXml = (string: string): string =>\n string\n .replace(/&/g, '&')\n .replace(/\"/g, '"')\n .replace(/'/g, ''')\n .replace(//g, '>');\n\n/**\n * Divide a string in the user perceived single units\n * @param {String} textstring String to escape\n * @return {Array} array containing the graphemes\n */\nexport const graphemeSplit = (textstring: string): string[] => {\n const graphemes = [];\n for (let i = 0, chr; i < textstring.length; i++) {\n if ((chr = getWholeChar(textstring, i)) === false) {\n continue;\n }\n graphemes.push(chr as string);\n }\n return graphemes;\n};\n\n// taken from mdn in the charAt doc page.\nconst getWholeChar = (str: string, i: number): string | boolean => {\n const code = str.charCodeAt(i);\n if (isNaN(code)) {\n return ''; // Position not found\n }\n if (code < 0xd800 || code > 0xdfff) {\n return str.charAt(i);\n }\n\n // High surrogate (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 <= code && code <= 0xdbff) {\n if (str.length <= i + 1) {\n throw 'High surrogate without following low surrogate';\n }\n const next = str.charCodeAt(i + 1);\n if (0xdc00 > next || next > 0xdfff) {\n throw 'High surrogate without following low surrogate';\n }\n return str.charAt(i) + str.charAt(i + 1);\n }\n // Low surrogate (0xDC00 <= code && code <= 0xDFFF)\n if (i === 0) {\n throw 'Low surrogate without preceding high surrogate';\n }\n const prev = str.charCodeAt(i - 1);\n\n // (could change last hex to 0xDB7F to treat high private\n // surrogates as single characters)\n if (0xd800 > prev || prev > 0xdbff) {\n throw 'Low surrogate without preceding high surrogate';\n }\n // We can pass over low surrogates now as the second component\n // in a pair which we have already processed\n return false;\n};\n","import { reNewline } from '../../constants';\nimport type {\n TextStyle,\n TextStyleDeclaration,\n} from '../../shapes/Text/StyledText';\nimport { cloneStyles } from '../internals/cloneStyles';\nimport { graphemeSplit } from '../lang_string';\n\nexport type TextStyleArray = {\n start: number;\n end: number;\n style: TextStyleDeclaration;\n}[];\n\n/**\n * @param {Object} prevStyle first style to compare\n * @param {Object} thisStyle second style to compare\n * @param {boolean} forTextSpans whether to check overline, underline, and line-through properties\n * @return {boolean} true if the style changed\n */\nexport const hasStyleChanged = (\n prevStyle: TextStyleDeclaration,\n thisStyle: TextStyleDeclaration,\n forTextSpans = false,\n) =>\n prevStyle.fill !== thisStyle.fill ||\n prevStyle.stroke !== thisStyle.stroke ||\n prevStyle.strokeWidth !== thisStyle.strokeWidth ||\n prevStyle.fontSize !== thisStyle.fontSize ||\n prevStyle.fontFamily !== thisStyle.fontFamily ||\n prevStyle.fontWeight !== thisStyle.fontWeight ||\n prevStyle.fontStyle !== thisStyle.fontStyle ||\n prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||\n prevStyle.deltaY !== thisStyle.deltaY ||\n (forTextSpans &&\n (prevStyle.overline !== thisStyle.overline ||\n prevStyle.underline !== thisStyle.underline ||\n prevStyle.linethrough !== thisStyle.linethrough));\n\n/**\n * Returns the array form of a text object's inline styles property with styles grouped in ranges\n * rather than per character. This format is less verbose, and is better suited for storage\n * so it is used in serialization (not during runtime).\n * @param {object} styles per character styles for a text object\n * @param {String} text the text string that the styles are applied to\n * @return {{start: number, end: number, style: object}[]}\n */\nexport const stylesToArray = (\n styles: TextStyle,\n text: string,\n): TextStyleArray => {\n const textLines = text.split('\\n'),\n stylesArray = [];\n let charIndex = -1,\n prevStyle = {};\n // clone style structure to prevent mutation\n styles = cloneStyles(styles);\n\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n if (!styles[i]) {\n //no styles exist for this line, so add the line's length to the charIndex total and reset prevStyle\n charIndex += chars.length;\n prevStyle = {};\n continue;\n }\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n const thisStyle = styles[i][c];\n //check if style exists for this character\n if (thisStyle && Object.keys(thisStyle).length > 0) {\n if (hasStyleChanged(prevStyle, thisStyle, true)) {\n stylesArray.push({\n start: charIndex,\n end: charIndex + 1,\n style: thisStyle,\n });\n } else {\n //if style is the same as previous character, increase end index\n stylesArray[stylesArray.length - 1].end++;\n }\n }\n prevStyle = thisStyle || {};\n }\n }\n return stylesArray;\n};\n\n/**\n * Returns the object form of the styles property with styles that are assigned per\n * character rather than grouped by range. This format is more verbose, and is\n * only used during runtime (not for serialization/storage)\n * @param {Array} styles the serialized form of a text object's styles\n * @param {String} text the text string that the styles are applied to\n * @return {Object}\n */\nexport const stylesFromArray = (\n styles: TextStyleArray | TextStyle,\n text: string,\n): TextStyle => {\n if (!Array.isArray(styles)) {\n // clone to prevent mutation\n return cloneStyles(styles);\n }\n const textLines = text.split(reNewline),\n stylesObject: TextStyle = {};\n let charIndex = -1,\n styleIndex = 0;\n //loop through each textLine\n for (let i = 0; i < textLines.length; i++) {\n const chars = graphemeSplit(textLines[i]);\n\n //loop through each character of the current line\n for (let c = 0; c < chars.length; c++) {\n charIndex++;\n //check if there's a style collection that includes the current character\n if (\n styles[styleIndex] &&\n styles[styleIndex].start <= charIndex &&\n charIndex < styles[styleIndex].end\n ) {\n //create object for line index if it doesn't exist\n stylesObject[i] = stylesObject[i] || {};\n //assign a style at this character's index\n stylesObject[i][c] = { ...styles[styleIndex].style };\n //if character is at the end of the current style collection, move to the next\n if (charIndex === styles[styleIndex].end - 1) {\n styleIndex++;\n }\n }\n }\n }\n return stylesObject;\n};\n","import { FILL, STROKE } from '../constants';\n\n/**\n * Attributes parsed from all SVG elements\n * @type array\n */\nexport const SHARED_ATTRIBUTES = [\n 'display',\n 'transform',\n FILL,\n 'fill-opacity',\n 'fill-rule',\n 'opacity',\n STROKE,\n 'stroke-dasharray',\n 'stroke-linecap',\n 'stroke-dashoffset',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke-width',\n 'id',\n 'paint-order',\n 'vector-effect',\n 'instantiated_by_use',\n 'clip-path',\n];\n","export function selectorMatches(element: HTMLElement, selector: string) {\n const nodeName = element.nodeName;\n const classNames = element.getAttribute('class');\n const id = element.getAttribute('id');\n const azAz = '(?![a-zA-Z\\\\-]+)';\n let matcher;\n // i check if a selector matches slicing away part from it.\n // if i get empty string i should match\n matcher = new RegExp('^' + nodeName, 'i');\n selector = selector.replace(matcher, '');\n if (id && selector.length) {\n matcher = new RegExp('#' + id + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n if (classNames && selector.length) {\n const splitClassNames = classNames.split(' ');\n for (let i = splitClassNames.length; i--; ) {\n matcher = new RegExp('\\\\.' + splitClassNames[i] + azAz, 'i');\n selector = selector.replace(matcher, '');\n }\n }\n return selector.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\n\nexport function doesSomeParentMatch(element: HTMLElement, selectors: string[]) {\n let selector: string,\n parentMatching = true;\n while (\n element.parentElement &&\n element.parentElement.nodeType === 1 &&\n selectors.length\n ) {\n if (parentMatching) {\n selector = selectors.pop()!;\n }\n element = element.parentElement;\n parentMatching = selectorMatches(element, selector!);\n }\n return selectors.length === 0;\n}\n","import { selectorMatches } from './selectorMatches';\nimport { doesSomeParentMatch } from './doesSomeParentMatch';\n\n/**\n * @private\n */\n\nexport function elementMatchesRule(element: HTMLElement, selectors: string[]) {\n let parentMatching = true;\n // start from rightmost selector.\n const firstMatching = selectorMatches(element, selectors.pop()!);\n if (firstMatching && selectors.length) {\n parentMatching = doesSomeParentMatch(element, selectors);\n }\n return firstMatching && parentMatching && selectors.length === 0;\n}\n","import { elementMatchesRule } from './elementMatchesRule';\nimport type { CSSRules } from './typedefs';\n\n/**\n * @private\n */\n\nexport function getGlobalStylesForElement(\n element: HTMLElement,\n cssRules: CSSRules = {},\n) {\n let styles: Record = {};\n for (const rule in cssRules) {\n if (elementMatchesRule(element, rule.split(' '))) {\n styles = {\n ...styles,\n ...cssRules[rule],\n };\n }\n }\n return styles;\n}\n","import { attributesMap } from './constants';\n\nexport const normalizeAttr = (\n attr: keyof typeof attributesMap | string,\n): string => attributesMap[attr as keyof typeof attributesMap] ?? attr;\n","import { reNum } from '../../parser/constants';\n\nconst regex = new RegExp(`(${reNum})`, 'gi');\n\nexport const cleanupSvgAttribute = (attributeValue: string) =>\n attributeValue\n .replace(regex, ' $1 ')\n // replace annoying commas and arbitrary whitespace with single spaces\n .replace(/,/gi, ' ')\n .replace(/\\s+/gi, ' ');\n","import { ROTATE, SCALE, SKEW_X, SKEW_Y, iMatrix } from '../constants';\nimport { reNum } from './constants';\nimport type { TMat2D } from '../typedefs';\nimport { cleanupSvgAttribute } from '../util/internals/cleanupSvgAttribute';\nimport {\n createRotateMatrix,\n createScaleMatrix,\n createSkewXMatrix,\n createSkewYMatrix,\n createTranslateMatrix,\n multiplyTransformMatrixArray,\n} from '../util/misc/matrix';\n\n// == begin transform regexp\nconst p = `(${reNum})`;\nconst skewX = String.raw`(skewX)\\(${p}\\)`;\nconst skewY = String.raw`(skewY)\\(${p}\\)`;\nconst rotate = String.raw`(rotate)\\(${p}(?: ${p} ${p})?\\)`;\nconst scale = String.raw`(scale)\\(${p}(?: ${p})?\\)`;\nconst translate = String.raw`(translate)\\(${p}(?: ${p})?\\)`;\nconst matrix = String.raw`(matrix)\\(${p} ${p} ${p} ${p} ${p} ${p}\\)`;\nconst transform = `(?:${matrix}|${translate}|${rotate}|${scale}|${skewX}|${skewY})`;\nconst transforms = `(?:${transform}*)`;\nconst transformList = String.raw`^\\s*(?:${transforms}?)\\s*$`;\n// http://www.w3.org/TR/SVG/coords.html#TransformAttribute\nconst reTransformList = new RegExp(transformList);\nconst reTransform = new RegExp(transform);\nconst reTransformAll = new RegExp(transform, 'g');\n// == end transform regexp\n\n/**\n * Parses \"transform\" attribute, returning an array of values\n * @static\n * @function\n * @memberOf fabric\n * @param {String} attributeValue String containing attribute value\n * @return {TTransformMatrix} Array of 6 elements representing transformation matrix\n */\nexport function parseTransformAttribute(attributeValue: string): TMat2D {\n // first we clean the string\n attributeValue = cleanupSvgAttribute(attributeValue)\n // remove spaces around front parentheses\n .replace(/\\s*([()])\\s*/gi, '$1');\n\n // start with identity matrix\n const matrices: TMat2D[] = [];\n\n // return if no argument was given or\n // an argument does not match transform attribute regexp\n if (\n !attributeValue ||\n (attributeValue && !reTransformList.test(attributeValue))\n ) {\n return [...iMatrix];\n }\n\n for (const match of attributeValue.matchAll(reTransformAll)) {\n const transformMatch = reTransform.exec(match[0]);\n if (!transformMatch) {\n continue;\n }\n let matrix: TMat2D = iMatrix;\n const matchedParams = transformMatch.filter((m) => !!m);\n const [, operation, ...rawArgs] = matchedParams;\n const [arg0, arg1, arg2, arg3, arg4, arg5] = rawArgs.map((arg) =>\n parseFloat(arg),\n );\n\n switch (operation) {\n case 'translate':\n matrix = createTranslateMatrix(arg0, arg1);\n break;\n case ROTATE:\n matrix = createRotateMatrix({ angle: arg0 }, { x: arg1, y: arg2 });\n break;\n case SCALE:\n matrix = createScaleMatrix(arg0, arg1);\n break;\n case SKEW_X:\n matrix = createSkewXMatrix(arg0);\n break;\n case SKEW_Y:\n matrix = createSkewYMatrix(arg0);\n break;\n case 'matrix':\n matrix = [arg0, arg1, arg2, arg3, arg4, arg5];\n break;\n }\n\n // snapshot current matrix into matrices array\n matrices.push(matrix);\n }\n\n return multiplyTransformMatrixArray(matrices);\n}\n","import { multiplyTransformMatrices } from '../util/misc/matrix';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { parseTransformAttribute } from './parseTransformAttribute';\nimport { CENTER, LEFT, RIGHT, NONE, FILL, STROKE } from '../constants';\n\nexport function normalizeValue(\n attr: string,\n value: any,\n parentAttributes: Record,\n fontSize: number,\n): string | null | boolean | number[] | number {\n const isArray = Array.isArray(value);\n let parsed: number | number[];\n let ouputValue: string | null | boolean | number[] | number = value;\n if ((attr === FILL || attr === STROKE) && value === NONE) {\n ouputValue = '';\n } else if (attr === 'strokeUniform') {\n return value === 'non-scaling-stroke';\n } else if (attr === 'strokeDashArray') {\n if (value === NONE) {\n ouputValue = null;\n } else {\n ouputValue = value.replace(/,/g, ' ').split(/\\s+/).map(parseFloat);\n }\n } else if (attr === 'transformMatrix') {\n if (parentAttributes && parentAttributes.transformMatrix) {\n ouputValue = multiplyTransformMatrices(\n parentAttributes.transformMatrix,\n parseTransformAttribute(value),\n );\n } else {\n ouputValue = parseTransformAttribute(value);\n }\n } else if (attr === 'visible') {\n ouputValue = value !== NONE && value !== 'hidden';\n // display=none on parent element always takes precedence over child element\n if (parentAttributes && parentAttributes.visible === false) {\n ouputValue = false;\n }\n } else if (attr === 'opacity') {\n ouputValue = parseFloat(value);\n if (parentAttributes && typeof parentAttributes.opacity !== 'undefined') {\n ouputValue *= parentAttributes.opacity as number;\n }\n } else if (attr === 'textAnchor' /* text-anchor */) {\n ouputValue = value === 'start' ? LEFT : value === 'end' ? RIGHT : CENTER;\n } else if (attr === 'charSpacing') {\n // parseUnit returns px and we convert it to em\n parsed = (parseUnit(value, fontSize) / fontSize) * 1000;\n } else if (attr === 'paintFirst') {\n const fillIndex = value.indexOf(FILL);\n const strokeIndex = value.indexOf(STROKE);\n ouputValue = FILL;\n if (fillIndex > -1 && strokeIndex > -1 && strokeIndex < fillIndex) {\n ouputValue = STROKE;\n } else if (fillIndex === -1 && strokeIndex > -1) {\n ouputValue = STROKE;\n }\n } else if (\n attr === 'href' ||\n attr === 'xlink:href' ||\n attr === 'font' ||\n attr === 'id'\n ) {\n return value;\n } else if (attr === 'imageSmoothing') {\n return value === 'optimizeQuality';\n } else {\n parsed = isArray\n ? (value as string[]).map(parseUnit)\n : parseUnit(value, fontSize);\n }\n\n return !isArray && isNaN(parsed! as number) ? ouputValue : parsed!;\n}\n","import { parseUnit } from '../util/misc/svgParsing';\nimport { reFontDeclaration } from './constants';\n\n/**\n * Parses a short font declaration, building adding its properties to a style object\n * @static\n * @function\n * @memberOf fabric\n * @param {String} value font declaration\n * @param {Object} oStyle definition\n */\nexport function parseFontDeclaration(\n value: string,\n oStyle: Record,\n): void {\n const match = value.match(reFontDeclaration);\n\n if (!match) {\n return;\n }\n const fontStyle = match[1],\n // font variant is not used\n // fontVariant = match[2],\n fontWeight = match[3],\n fontSize = match[4],\n lineHeight = match[5],\n fontFamily = match[6];\n\n if (fontStyle) {\n oStyle.fontStyle = fontStyle;\n }\n if (fontWeight) {\n oStyle.fontWeight = isNaN(parseFloat(fontWeight))\n ? fontWeight\n : parseFloat(fontWeight);\n }\n if (fontSize) {\n oStyle.fontSize = parseUnit(fontSize);\n }\n if (fontFamily) {\n oStyle.fontFamily = fontFamily;\n }\n if (lineHeight) {\n oStyle.lineHeight = lineHeight === 'normal' ? 1 : lineHeight;\n }\n}\n","/**\n * Takes a style object and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleObject(\n style: Record,\n oStyle: Record,\n): void {\n Object.entries(style).forEach(([prop, value]) => {\n if (value === undefined) {\n return;\n }\n oStyle[prop.toLowerCase()] = value;\n });\n}\n","/**\n * Takes a style string and parses it in one that has only defined values\n * and lowercases properties\n * @param style\n * @param oStyle\n */\nexport function parseStyleString(\n style: string,\n oStyle: Record,\n): void {\n style\n .replace(/;\\s*$/, '')\n .split(';')\n .forEach((chunk) => {\n if (!chunk) return;\n const [attr, value] = chunk.split(':');\n oStyle[attr.trim().toLowerCase()] = value.trim();\n });\n}\n","import { parseStyleObject } from './parseStyleObject';\nimport { parseStyleString } from './parseStyleString';\n\n/**\n * Parses \"style\" attribute, retuning an object with values\n * @static\n * @memberOf fabric\n * @param {SVGElement} element Element to parse\n * @return {Object} Objects with values parsed from style attribute of an element\n */\nexport function parseStyleAttribute(element: HTMLElement): Record {\n const oStyle: Record = {},\n style = element.getAttribute('style');\n\n if (!style) {\n return oStyle;\n }\n\n if (typeof style === 'string') {\n parseStyleString(style, oStyle);\n } else {\n parseStyleObject(style, oStyle);\n }\n\n return oStyle;\n}\n","import { Color } from '../color/Color';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject } from '../shapes/Object/FabricObject';\n\nconst colorAttributesMap = {\n stroke: 'strokeOpacity',\n fill: 'fillOpacity',\n};\n\n/**\n * @private\n * @param {Object} attributes Array of attributes to parse\n */\n\nexport function setStrokeFillOpacity(\n attributes: Record,\n): Record {\n const defaults = FabricObject.getDefaults();\n Object.entries(colorAttributesMap).forEach(([attr, colorAttr]) => {\n if (\n typeof attributes[colorAttr] === 'undefined' ||\n attributes[attr] === ''\n ) {\n return;\n }\n if (typeof attributes[attr] === 'undefined') {\n if (!defaults[attr]) {\n return;\n }\n attributes[attr] = defaults[attr];\n }\n if (attributes[attr].indexOf('url(') === 0) {\n return;\n }\n const color = new Color(attributes[attr]);\n attributes[attr] = color\n .setAlpha(toFixed(color.getAlpha() * attributes[colorAttr], 2))\n .toRgba();\n });\n return attributes;\n}\n","import { DEFAULT_SVG_FONT_SIZE } from '../constants';\nimport { parseUnit } from '../util/misc/svgParsing';\nimport { cPath, fSize, svgValidParentsRegEx } from './constants';\nimport { getGlobalStylesForElement } from './getGlobalStylesForElement';\nimport { normalizeAttr } from './normalizeAttr';\nimport { normalizeValue } from './normalizeValue';\nimport { parseFontDeclaration } from './parseFontDeclaration';\nimport { parseStyleAttribute } from './parseStyleAttribute';\nimport { setStrokeFillOpacity } from './setStrokeFillOpacity';\nimport type { CSSRules } from './typedefs';\n\n/**\n * Returns an object of attributes' name/value, given element and an array of attribute names;\n * Parses parent \"g\" nodes recursively upwards.\n * @param {SVGElement | HTMLElement} element Element to parse\n * @param {Array} attributes Array of attributes to parse\n * @return {Object} object containing parsed attributes' names/values\n */\nexport function parseAttributes(\n element: HTMLElement | null,\n attributes: string[],\n cssRules?: CSSRules,\n): Record {\n if (!element) {\n return {};\n }\n\n let parentAttributes: Record = {},\n fontSize: number,\n parentFontSize = DEFAULT_SVG_FONT_SIZE;\n\n // if there's a parent container (`g` or `a` or `symbol` node), parse its attributes recursively upwards\n if (\n element.parentNode &&\n svgValidParentsRegEx.test(element.parentNode.nodeName)\n ) {\n parentAttributes = parseAttributes(\n element.parentElement,\n attributes,\n cssRules,\n );\n if (parentAttributes.fontSize) {\n fontSize = parentFontSize = parseUnit(parentAttributes.fontSize);\n }\n }\n\n const ownAttributes: Record = {\n ...attributes.reduce>((memo, attr) => {\n const value = element.getAttribute(attr);\n if (value) {\n memo[attr] = value;\n }\n return memo;\n }, {}),\n // add values parsed from style, which take precedence over attributes\n // (see: http://www.w3.org/TR/SVG/styling.html#UsingPresentationAttributes)\n ...getGlobalStylesForElement(element, cssRules),\n ...parseStyleAttribute(element),\n };\n\n if (ownAttributes[cPath]) {\n element.setAttribute(cPath, ownAttributes[cPath]);\n }\n if (ownAttributes[fSize]) {\n // looks like the minimum should be 9px when dealing with ems. this is what looks like in browsers.\n fontSize = parseUnit(ownAttributes[fSize], parentFontSize);\n ownAttributes[fSize] = `${fontSize}`;\n }\n\n // this should have its own complex type\n const normalizedStyle: Record<\n string,\n string | boolean | number | number[] | null\n > = {};\n for (const attr in ownAttributes) {\n const normalizedAttr = normalizeAttr(attr);\n const normalizedValue = normalizeValue(\n normalizedAttr,\n ownAttributes[attr],\n parentAttributes,\n fontSize!,\n );\n normalizedStyle[normalizedAttr] = normalizedValue;\n }\n if (normalizedStyle && normalizedStyle.font) {\n parseFontDeclaration(normalizedStyle.font as string, normalizedStyle);\n }\n const mergedAttrs = { ...parentAttributes, ...normalizedStyle };\n return svgValidParentsRegEx.test(element.nodeName)\n ? mergedAttrs\n : setStrokeFillOpacity(mergedAttrs);\n}\n","import { kRect } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const rectDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueRectProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedRectProps\n extends SerializedObjectProps,\n UniqueRectProps {}\n\nexport interface RectProps extends FabricObjectProps, UniqueRectProps {}\n\nconst RECT_PROPS = ['rx', 'ry'] as const;\n\nexport class Rect<\n Props extends TOptions = Partial,\n SProps extends SerializedRectProps = SerializedRectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements RectProps\n{\n /**\n * Horizontal border radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical border radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Rect';\n\n static cacheProperties = [...cacheProperties, ...RECT_PROPS];\n\n static ownDefaults = rectDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Rect.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Rect.ownDefaults);\n this.setOptions(options);\n this._initRxRy();\n }\n /**\n * Initializes rx/ry attributes\n * @private\n */\n _initRxRy() {\n const { rx, ry } = this;\n if (rx && !ry) {\n this.ry = rx;\n } else if (ry && !rx) {\n this.rx = ry;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const { width: w, height: h } = this;\n const x = -w / 2;\n const y = -h / 2;\n const rx = this.rx ? Math.min(this.rx, w / 2) : 0;\n const ry = this.ry ? Math.min(this.ry, h / 2) : 0;\n const isRounded = rx !== 0 || ry !== 0;\n\n ctx.beginPath();\n\n ctx.moveTo(x + rx, y);\n\n ctx.lineTo(x + w - rx, y);\n isRounded &&\n ctx.bezierCurveTo(\n x + w - kRect * rx,\n y,\n x + w,\n y + kRect * ry,\n x + w,\n y + ry,\n );\n\n ctx.lineTo(x + w, y + h - ry);\n isRounded &&\n ctx.bezierCurveTo(\n x + w,\n y + h - kRect * ry,\n x + w - kRect * rx,\n y + h,\n x + w - rx,\n y + h,\n );\n\n ctx.lineTo(x + rx, y + h);\n isRounded &&\n ctx.bezierCurveTo(\n x + kRect * rx,\n y + h,\n x,\n y + h - kRect * ry,\n x,\n y + h - ry,\n );\n\n ctx.lineTo(x, y + ry);\n isRounded &&\n ctx.bezierCurveTo(x, y + kRect * ry, x + kRect * rx, y, x + rx, y);\n\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...RECT_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { width, height, rx, ry } = this;\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Rect.fromElement`)\n * @static\n * @memberOf Rect\n * @see: http://www.w3.org/TR/SVG/shapes.html#RectElement\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'rx',\n 'ry',\n 'width',\n 'height',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns {@link Rect} instance from an SVG element\n * @static\n * @memberOf Rect\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n left = 0,\n top = 0,\n width = 0,\n height = 0,\n visible = true,\n ...restOfparsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n\n return new this({\n ...options,\n ...restOfparsedAttributes,\n left,\n top,\n width,\n height,\n visible: Boolean(visible && width && height),\n });\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Rect);\nclassRegistry.setSVGClass(Rect);\n","export const LAYOUT_TYPE_INITIALIZATION = 'initialization';\nexport const LAYOUT_TYPE_ADDED = 'added';\nexport const LAYOUT_TYPE_REMOVED = 'removed';\nexport const LAYOUT_TYPE_IMPERATIVE = 'imperative';\nexport const LAYOUT_TYPE_OBJECT_MODIFIED = 'object_modified';\nexport const LAYOUT_TYPE_OBJECT_MODIFYING = 'object_modifying';\n","import { Point, ZERO } from '../../Point';\nimport type { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { multiplyTransformMatrixArray } from '../../util/misc/matrix';\nimport { sizeAfterTransform } from '../../util/misc/objectTransforms';\nimport {\n calcPlaneChangeMatrix,\n sendVectorToPlane,\n} from '../../util/misc/planeChange';\n\n/**\n * @returns 2 points, the tl and br corners of the non rotated bounding box of an object\n * in the {@link group} plane, taking into account objects that {@link group} is their parent\n * but also belong to the active selection.\n */\nexport const getObjectBounds = (\n destinationGroup: Group,\n object: FabricObject,\n): Point[] => {\n const {\n strokeUniform,\n strokeWidth,\n width,\n height,\n group: currentGroup,\n } = object;\n const t =\n currentGroup && currentGroup !== destinationGroup\n ? calcPlaneChangeMatrix(\n currentGroup.calcTransformMatrix(),\n destinationGroup.calcTransformMatrix(),\n )\n : null;\n const objectCenter = t\n ? object.getRelativeCenterPoint().transform(t)\n : object.getRelativeCenterPoint();\n const accountForStroke = !object['isStrokeAccountedForInDimensions']();\n const strokeUniformVector =\n strokeUniform && accountForStroke\n ? sendVectorToPlane(\n new Point(strokeWidth, strokeWidth),\n undefined,\n destinationGroup.calcTransformMatrix(),\n )\n : ZERO;\n const scalingStrokeWidth =\n !strokeUniform && accountForStroke ? strokeWidth : 0;\n const sizeVector = sizeAfterTransform(\n width + scalingStrokeWidth,\n height + scalingStrokeWidth,\n multiplyTransformMatrixArray([t, object.calcOwnMatrix()], true),\n )\n .add(strokeUniformVector)\n .scalarDivide(2);\n return [objectCenter.subtract(sizeVector), objectCenter.add(sizeVector)];\n};\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_IMPERATIVE,\n} from '../constants';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { getObjectBounds } from './utils';\n\n/**\n * Exposes a main public method {@link calcLayoutResult} that is used by the `LayoutManager` to perform layout.\n * Returning `undefined` signals the `LayoutManager` to skip the layout.\n *\n * In charge of calculating the bounding box of the passed objects.\n */\nexport abstract class LayoutStrategy {\n /**\n * override by subclass for persistence (TS does not support `static abstract`)\n */\n static type = 'strategy';\n\n /**\n * Used by the `LayoutManager` to perform layout\n * @TODO/fix: if this method is calcResult, should calc unconditionally.\n * the condition to not calc should be evaluated by the layoutManager.\n * @returns layout result **OR** `undefined` to skip layout\n */\n public calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n if (this.shouldPerformLayout(context)) {\n return this.calcBoundingBox(objects, context);\n }\n }\n\n shouldPerformLayout({ type, prevStrategy, strategy }: StrictLayoutContext) {\n return (\n type === LAYOUT_TYPE_INITIALIZATION ||\n type === LAYOUT_TYPE_IMPERATIVE ||\n (!!prevStrategy && strategy !== prevStrategy)\n );\n }\n\n shouldLayoutClipPath({ type, target: { clipPath } }: StrictLayoutContext) {\n return (\n type !== LAYOUT_TYPE_INITIALIZATION &&\n clipPath &&\n !clipPath.absolutePositioned\n );\n }\n\n getInitialSize(\n context: StrictLayoutContext & InitializationLayoutContext,\n result: Pick,\n ) {\n return result.size;\n }\n\n /**\n * Override this method to customize layout.\n */\n calcBoundingBox(\n objects: FabricObject[],\n context: StrictLayoutContext,\n ): LayoutStrategyResult | undefined {\n const { type, target } = context;\n if (type === LAYOUT_TYPE_IMPERATIVE && context.overrides) {\n return context.overrides;\n }\n if (objects.length === 0) {\n return;\n }\n const { left, top, width, height } = makeBoundingBoxFromPoints(\n objects\n .map((object) => getObjectBounds(target, object))\n .reduce((coords, curr) => coords.concat(curr), []),\n );\n const bboxSize = new Point(width, height);\n const bboxLeftTop = new Point(left, top);\n const bboxCenter = bboxLeftTop.add(bboxSize.scalarDivide(2));\n\n if (type === LAYOUT_TYPE_INITIALIZATION) {\n const actualSize = this.getInitialSize(context, {\n size: bboxSize,\n center: bboxCenter,\n });\n return {\n // in `initialization` we do not account for target's transformation matrix\n center: bboxCenter,\n // TODO: investigate if this is still necessary\n relativeCorrection: new Point(0, 0),\n size: actualSize,\n };\n } else {\n // we send `relativeCenter` up to group's containing plane\n const center = bboxCenter.transform(target.calcOwnMatrix());\n return {\n center,\n size: bboxSize,\n };\n }\n }\n}\n","import type { StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to fit target's objects.\n */\nexport class FitContentLayout extends LayoutStrategy {\n static readonly type = 'fit-content';\n\n /**\n * @override layout on all triggers\n * Override at will\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldPerformLayout(context: StrictLayoutContext) {\n return true;\n }\n}\n\nclassRegistry.setClass(FitContentLayout);\n","import { Point } from '../Point';\nimport {\n CENTER,\n CHANGED,\n MODIFIED,\n MODIFY_PATH,\n MODIFY_POLY,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n iMatrix,\n} from '../constants';\nimport type { Group } from '../shapes/Group';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { invertTransform } from '../util/misc/matrix';\nimport { resolveOrigin } from '../util/misc/resolveOrigin';\nimport { FitContentLayout } from './LayoutStrategies/FitContentLayout';\nimport type { LayoutStrategy } from './LayoutStrategies/LayoutStrategy';\nimport {\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_OBJECT_MODIFIED,\n LAYOUT_TYPE_OBJECT_MODIFYING,\n} from './constants';\nimport type {\n LayoutContext,\n LayoutResult,\n RegistrationContext,\n StrictLayoutContext,\n} from './types';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TModificationEvents } from '../EventTypeDefs';\n\nconst LAYOUT_MANAGER = 'layoutManager';\n\nexport type SerializedLayoutManager = {\n type: string;\n strategy: string;\n};\n\nexport class LayoutManager {\n private declare _prevLayoutStrategy?: LayoutStrategy;\n protected declare _subscriptions: Map;\n\n strategy: LayoutStrategy;\n\n constructor(strategy: LayoutStrategy = new FitContentLayout()) {\n this.strategy = strategy;\n this._subscriptions = new Map();\n }\n\n public performLayout(context: LayoutContext) {\n const strictContext: StrictLayoutContext = {\n bubbles: true,\n strategy: this.strategy,\n ...context,\n prevStrategy: this._prevLayoutStrategy,\n stopPropagation() {\n this.bubbles = false;\n },\n };\n\n this.onBeforeLayout(strictContext);\n\n const layoutResult = this.getLayoutResult(strictContext);\n if (layoutResult) {\n this.commitLayout(strictContext, layoutResult);\n }\n\n this.onAfterLayout(strictContext, layoutResult);\n this._prevLayoutStrategy = strictContext.strategy;\n }\n\n /**\n * Attach handlers for events that we know will invalidate the layout when\n * performed on child objects ( general transforms ).\n * Returns the disposers for later unsubscribing and cleanup\n * @param {FabricObject} object\n * @param {RegistrationContext & Partial} context\n * @returns {VoidFunction[]} disposers remove the handlers\n */\n protected attachHandlers(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ): VoidFunction[] {\n const { target } = context;\n return (\n [\n MODIFIED,\n MOVING,\n RESIZING,\n ROTATING,\n SCALING,\n SKEWING,\n CHANGED,\n MODIFY_POLY,\n MODIFY_PATH,\n ] as (TModificationEvents & 'modified')[]\n ).map((key) =>\n object.on(key, (e) =>\n this.performLayout(\n key === MODIFIED\n ? {\n type: LAYOUT_TYPE_OBJECT_MODIFIED,\n trigger: key,\n e,\n target,\n }\n : {\n type: LAYOUT_TYPE_OBJECT_MODIFYING,\n trigger: key,\n e,\n target,\n },\n ),\n ),\n );\n }\n\n /**\n * Subscribe an object to transform events that will trigger a layout change on the parent\n * This is important only for interactive groups.\n * @param object\n * @param context\n */\n protected subscribe(\n object: FabricObject,\n context: RegistrationContext & Partial,\n ) {\n this.unsubscribe(object, context);\n const disposers = this.attachHandlers(object, context);\n this._subscriptions.set(object, disposers);\n }\n\n /**\n * unsubscribe object layout triggers\n */\n protected unsubscribe(\n object: FabricObject,\n _context?: RegistrationContext & Partial,\n ) {\n (this._subscriptions.get(object) || []).forEach((d) => d());\n this._subscriptions.delete(object);\n }\n\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.unsubscribe(object, context));\n }\n\n subscribeTargets(\n context: RegistrationContext & Partial,\n ) {\n context.targets.forEach((object) => this.subscribe(object, context));\n }\n\n protected onBeforeLayout(context: StrictLayoutContext) {\n const { target, type } = context;\n const { canvas } = target;\n // handle layout triggers subscription\n // @TODO: gate the registration when the group is interactive\n if (type === LAYOUT_TYPE_INITIALIZATION || type === LAYOUT_TYPE_ADDED) {\n this.subscribeTargets(context);\n } else if (type === LAYOUT_TYPE_REMOVED) {\n this.unsubscribeTargets(context);\n }\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:before', {\n context,\n });\n canvas &&\n canvas.fire('object:layout:before', {\n target,\n context,\n });\n\n if (type === LAYOUT_TYPE_IMPERATIVE && context.deep) {\n const { strategy: _, ...tricklingContext } = context;\n // traverse the tree\n target.forEachObject(\n (object) =>\n (object as Group).layoutManager &&\n (object as Group).layoutManager.performLayout({\n ...tricklingContext,\n bubbles: false,\n target: object as Group,\n }),\n );\n }\n }\n\n protected getLayoutResult(\n context: StrictLayoutContext,\n ): Required | undefined {\n const { target, strategy, type } = context;\n\n const result = strategy.calcLayoutResult(context, target.getObjects());\n\n if (!result) {\n return;\n }\n\n const prevCenter =\n type === LAYOUT_TYPE_INITIALIZATION\n ? new Point()\n : target.getRelativeCenterPoint();\n\n const {\n center: nextCenter,\n correction = new Point(),\n relativeCorrection = new Point(),\n } = result;\n const offset = prevCenter\n .subtract(nextCenter)\n .add(correction)\n .transform(\n // in `initialization` we do not account for target's transformation matrix\n type === LAYOUT_TYPE_INITIALIZATION\n ? iMatrix\n : invertTransform(target.calcOwnMatrix()),\n true,\n )\n .add(relativeCorrection);\n\n return {\n result,\n prevCenter,\n nextCenter,\n offset,\n };\n }\n\n protected commitLayout(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n const {\n result: { size },\n nextCenter,\n } = layoutResult;\n // set dimensions\n target.set({ width: size.x, height: size.y });\n // layout descendants\n this.layoutObjects(context, layoutResult);\n // set position\n // in `initialization` we do not account for target's transformation matrix\n if (context.type === LAYOUT_TYPE_INITIALIZATION) {\n // TODO: what about strokeWidth?\n target.set({\n left:\n context.x ?? nextCenter.x + size.x * resolveOrigin(target.originX),\n top: context.y ?? nextCenter.y + size.y * resolveOrigin(target.originY),\n });\n } else {\n target.setPositionByOrigin(nextCenter, CENTER, CENTER);\n // invalidate\n target.setCoords();\n target.set('dirty', true);\n }\n }\n\n protected layoutObjects(\n context: StrictLayoutContext,\n layoutResult: Required,\n ) {\n const { target } = context;\n // adjust objects to account for new center\n target.forEachObject((object) => {\n object.group === target &&\n this.layoutObject(context, layoutResult, object);\n });\n // adjust clip path to account for new center\n context.strategy.shouldLayoutClipPath(context) &&\n this.layoutObject(context, layoutResult, target.clipPath as FabricObject);\n }\n\n /**\n * @param {FabricObject} object\n * @param {Point} offset\n */\n protected layoutObject(\n context: StrictLayoutContext,\n { offset }: Required,\n object: FabricObject,\n ) {\n // TODO: this is here for cache invalidation.\n // verify if this is necessary since we have explicit\n // cache invalidation at the end of commitLayout\n object.set({\n left: object.left + offset.x,\n top: object.top + offset.y,\n });\n }\n\n protected onAfterLayout(\n context: StrictLayoutContext,\n layoutResult?: LayoutResult,\n ) {\n const {\n target,\n strategy,\n bubbles,\n prevStrategy: _,\n ...bubblingContext\n } = context;\n const { canvas } = target;\n\n // fire layout event (event will fire only for layouts after initialization layout)\n target.fire('layout:after', {\n context,\n result: layoutResult,\n });\n canvas &&\n canvas.fire('object:layout:after', {\n context,\n result: layoutResult,\n target,\n });\n\n // bubble\n const parent = target.parent;\n if (bubbles && parent?.layoutManager) {\n // add target to context#path\n (bubblingContext.path || (bubblingContext.path = [])).push(target);\n // all parents should invalidate their layout\n parent.layoutManager.performLayout({\n ...bubblingContext,\n target: parent,\n });\n }\n target.set('dirty', true);\n }\n\n dispose() {\n const { _subscriptions } = this;\n _subscriptions.forEach((disposers) => disposers.forEach((d) => d()));\n _subscriptions.clear();\n }\n\n toObject() {\n return {\n type: LAYOUT_MANAGER,\n strategy: (this.strategy.constructor as typeof LayoutStrategy).type,\n };\n }\n\n toJSON() {\n return this.toObject();\n }\n}\n\nclassRegistry.setClass(LayoutManager, LAYOUT_MANAGER);\n","import type { CollectionEvents, ObjectEvents } from '../EventTypeDefs';\nimport { createCollectionMixin } from '../Collection';\nimport type {\n TClassProperties,\n TSVGReviver,\n TOptions,\n Abortable,\n} from '../typedefs';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n} from '../util/misc/matrix';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n} from '../util/misc/objectEnlive';\nimport { applyTransformToObject } from '../util/misc/objectTransforms';\nimport { FabricObject } from './Object/FabricObject';\nimport { Rect } from './Rect';\nimport { classRegistry } from '../ClassRegistry';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport { log } from '../util/internals/console';\nimport type {\n ImperativeLayoutOptions,\n LayoutBeforeEvent,\n LayoutAfterEvent,\n} from '../LayoutManager/types';\nimport { LayoutManager } from '../LayoutManager/LayoutManager';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_IMPERATIVE,\n LAYOUT_TYPE_INITIALIZATION,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { SerializedLayoutManager } from '../LayoutManager/LayoutManager';\nimport type { FitContentLayout } from '../LayoutManager';\nimport type { DrawContext } from './Object/Object';\n\n/**\n * This class handles the specific case of creating a group using {@link Group#fromObject} and is not meant to be used in any other case.\n * We could have used a boolean in the constructor, as we did previously, but we think the boolean\n * would stay in the group's constructor interface and create confusion, therefore it was removed.\n * This layout manager doesn't do anything and therefore keeps the exact layout the group had when {@link Group#toObject} was called.\n */\nclass NoopLayoutManager extends LayoutManager {\n performLayout() {}\n}\n\nexport interface GroupEvents extends ObjectEvents, CollectionEvents {\n 'layout:before': LayoutBeforeEvent;\n 'layout:after': LayoutAfterEvent;\n}\n\nexport interface GroupOwnProps {\n subTargetCheck: boolean;\n interactive: boolean;\n}\n\nexport interface SerializedGroupProps\n extends SerializedObjectProps,\n GroupOwnProps {\n objects: SerializedObjectProps[];\n layoutManager: SerializedLayoutManager;\n}\n\nexport interface GroupProps extends FabricObjectProps, GroupOwnProps {\n layoutManager: LayoutManager;\n}\n\nexport const groupDefaultValues: Partial> = {\n strokeWidth: 0,\n subTargetCheck: false,\n interactive: false,\n};\n\n/**\n * @fires object:added\n * @fires object:removed\n * @fires layout:before\n * @fires layout:after\n */\nexport class Group\n extends createCollectionMixin(\n FabricObject,\n )\n implements GroupProps\n{\n /**\n * Used to optimize performance\n * set to `false` if you don't need contained objects to be targets of events\n * @default\n * @type boolean\n */\n declare subTargetCheck: boolean;\n\n /**\n * Used to allow targeting of object inside groups.\n * set to true if you want to select an object inside a group.\\\n * **REQUIRES** `subTargetCheck` set to true\n * This will be not removed but slowly replaced with a method setInteractive\n * that will take care of enabling subTargetCheck and necessary object events.\n * There is too much attached to group interactivity to just be evaluated by a\n * boolean in the code\n * @default\n * @deprecated\n * @type boolean\n */\n declare interactive: boolean;\n\n declare layoutManager: LayoutManager;\n\n /**\n * Used internally to optimize performance\n * Once an object is selected, instance is rendered without the selected object.\n * This way instance is cached only once for the entire interaction with the selected object.\n * @private\n */\n protected _activeObjects: FabricObject[] = [];\n\n static type = 'Group';\n\n static ownDefaults: Record = groupDefaultValues;\n private __objectSelectionTracker: (ev: ObjectEvents['selected']) => void;\n private __objectSelectionDisposer: (ev: ObjectEvents['deselected']) => void;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Group.ownDefaults,\n };\n }\n\n /**\n * Constructor\n *\n * @param {FabricObject[]} [objects] instance objects\n * @param {Object} [options] Options object\n */\n constructor(objects: FabricObject[] = [], options: Partial = {}) {\n super();\n Object.assign(this, Group.ownDefaults);\n this.setOptions(options);\n this.groupInit(objects, options);\n }\n\n /**\n * Shared code between group and active selection\n * Meant to be used by the constructor.\n */\n protected groupInit(\n objects: FabricObject[],\n options: {\n layoutManager?: LayoutManager;\n top?: number;\n left?: number;\n },\n ) {\n this._objects = [...objects]; // Avoid unwanted mutations of Collection to affect the caller\n\n this.__objectSelectionTracker = this.__objectSelectionMonitor.bind(\n this,\n true,\n );\n this.__objectSelectionDisposer = this.__objectSelectionMonitor.bind(\n this,\n false,\n );\n\n this.forEachObject((object) => {\n this.enterGroup(object, false);\n });\n\n // perform initial layout\n this.layoutManager = options.layoutManager ?? new LayoutManager();\n this.layoutManager.performLayout({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: this,\n targets: [...objects],\n // @TODO remove this concept from the layout manager.\n // Layout manager will calculate the correct position,\n // group options can override it later.\n x: options.left,\n y: options.top,\n });\n }\n\n /**\n * Checks if object can enter group and logs relevant warnings\n * @private\n * @param {FabricObject} object\n * @returns\n */\n canEnterGroup(object: FabricObject) {\n if (object === this || this.isDescendantOf(object)) {\n // prevent circular object tree\n log(\n 'error',\n 'Group: circular object trees are not supported, this call has no effect',\n );\n return false;\n } else if (this._objects.indexOf(object) !== -1) {\n // is already in the objects array\n log(\n 'error',\n 'Group: duplicate objects are not supported inside group, this call has no effect',\n );\n return false;\n }\n return true;\n }\n\n /**\n * Override this method to enhance performance (for groups with a lot of objects).\n * If Overriding, be sure not pass illegal objects to group - it will break your app.\n * @private\n */\n protected _filterObjectsBeforeEnteringGroup(objects: FabricObject[]) {\n return objects.filter((object, index, array) => {\n // can enter AND is the first occurrence of the object in the passed args (to prevent adding duplicates)\n return this.canEnterGroup(object) && array.indexOf(object) === index;\n });\n }\n\n /**\n * Add objects\n * @param {...FabricObject[]} objects\n */\n add(...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.add(...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Inserts an object into collection at specified index\n * @param {FabricObject[]} objects Object to insert\n * @param {Number} index Index to insert object at\n */\n insertAt(index: number, ...objects: FabricObject[]) {\n const allowedObjects = this._filterObjectsBeforeEnteringGroup(objects);\n const size = super.insertAt(index, ...allowedObjects);\n this._onAfterObjectsChange(LAYOUT_TYPE_ADDED, allowedObjects);\n return size;\n }\n\n /**\n * Remove objects\n * @param {...FabricObject[]} objects\n * @returns {FabricObject[]} removed objects\n */\n remove(...objects: FabricObject[]) {\n const removed = super.remove(...objects);\n this._onAfterObjectsChange(LAYOUT_TYPE_REMOVED, removed);\n return removed;\n }\n\n _onObjectAdded(object: FabricObject) {\n this.enterGroup(object, true);\n this.fire('object:added', { target: object });\n object.fire('added', { target: this });\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _onObjectRemoved(object: FabricObject, removeParentTransform?: boolean) {\n this.exitGroup(object, removeParentTransform);\n this.fire('object:removed', { target: object });\n object.fire('removed', { target: this });\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n this.layoutManager.performLayout({\n type,\n targets,\n target: this,\n });\n }\n\n _onStackOrderChanged() {\n this._set('dirty', true);\n }\n\n /**\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n const prev = this[key as keyof this];\n super._set(key, value);\n if (key === 'canvas' && prev !== value) {\n (this._objects || []).forEach((object) => {\n object._set(key, value);\n });\n }\n return this;\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return this.subTargetCheck;\n }\n\n /**\n * Remove all objects\n * @returns {FabricObject[]} removed objects\n */\n removeAll() {\n this._activeObjects = [];\n return this.remove(...this._objects);\n }\n\n /**\n * keeps track of the selected objects\n * @private\n */\n __objectSelectionMonitor(\n selected: T,\n {\n target: object,\n }: ObjectEvents[T extends true ? 'selected' : 'deselected'],\n ) {\n const activeObjects = this._activeObjects;\n if (selected) {\n activeObjects.push(object);\n this._set('dirty', true);\n } else if (activeObjects.length > 0) {\n const index = activeObjects.indexOf(object);\n if (index > -1) {\n activeObjects.splice(index, 1);\n this._set('dirty', true);\n }\n }\n }\n\n /**\n * @private\n * @param {boolean} watch\n * @param {FabricObject} object\n */\n _watchObject(watch: boolean, object: FabricObject) {\n // make sure we listen only once\n watch && this._watchObject(false, object);\n if (watch) {\n object.on('selected', this.__objectSelectionTracker);\n object.on('deselected', this.__objectSelectionDisposer);\n } else {\n object.off('selected', this.__objectSelectionTracker);\n object.off('deselected', this.__objectSelectionDisposer);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n object.group && object.group.remove(object);\n object._set('parent', this);\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n _enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n if (removeParentTransform) {\n // can this be converted to utils (sendObjectToPlane)?\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n invertTransform(this.calcTransformMatrix()),\n object.calcTransformMatrix(),\n ),\n );\n }\n this._shouldSetNestedCoords() && object.setCoords();\n object._set('group', this);\n object._set('canvas', this.canvas);\n this._watchObject(true, object);\n const activeObject =\n this.canvas &&\n this.canvas.getActiveObject &&\n this.canvas.getActiveObject();\n // if we are adding the activeObject in a group\n if (\n activeObject &&\n (activeObject === object || object.isDescendantOf(activeObject))\n ) {\n this._activeObjects.push(object);\n }\n }\n\n /**\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n object._set('parent', undefined);\n object._set('canvas', undefined);\n }\n\n /**\n * Executes the inner fabric logic of exiting a group.\n * - Stop watching the object\n * - Remove the object from the optimization map this._activeObjects\n * - unset the group property of the object\n * @protected\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n _exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n object._set('group', undefined);\n if (!removeParentTransform) {\n applyTransformToObject(\n object,\n multiplyTransformMatrices(\n this.calcTransformMatrix(),\n object.calcTransformMatrix(),\n ),\n );\n object.setCoords();\n }\n this._watchObject(false, object);\n const index =\n this._activeObjects.length > 0 ? this._activeObjects.indexOf(object) : -1;\n if (index > -1) {\n this._activeObjects.splice(index, 1);\n }\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group is already cached.\n * @return {Boolean}\n */\n shouldCache() {\n const ownCache = FabricObject.prototype.shouldCache.call(this);\n if (ownCache) {\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n this.ownCaching = false;\n return false;\n }\n }\n }\n return ownCache;\n }\n\n /**\n * Check if this object or a child object will cast a shadow\n * @return {Boolean}\n */\n willDrawShadow() {\n if (super.willDrawShadow()) {\n return true;\n }\n for (let i = 0; i < this._objects.length; i++) {\n if (this._objects[i].willDrawShadow()) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Check if instance or its group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache(): boolean {\n return this.ownCaching || (!!this.parent && this.parent.isOnACache());\n }\n\n /**\n * Execute the drawing operation for an object on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawObject(\n ctx: CanvasRenderingContext2D,\n forClipping: boolean | undefined,\n context: DrawContext,\n ) {\n this._renderBackground(ctx);\n for (let i = 0; i < this._objects.length; i++) {\n const obj = this._objects[i];\n // TODO: handle rendering edge case somehow\n if (this.canvas?.preserveObjectStacking && obj.group !== this) {\n ctx.save();\n ctx.transform(...invertTransform(this.calcTransformMatrix()));\n obj.render(ctx);\n ctx.restore();\n } else if (obj.group === this) {\n obj.render(ctx);\n }\n }\n this._drawClipPath(ctx, this.clipPath, context);\n }\n\n /**\n * @override\n * @return {Boolean}\n */\n setCoords() {\n super.setCoords();\n this._shouldSetNestedCoords() &&\n this.forEachObject((object) => object.setCoords());\n }\n\n triggerLayout(options: ImperativeLayoutOptions = {}) {\n this.layoutManager.performLayout({\n target: this,\n type: LAYOUT_TYPE_IMPERATIVE,\n ...options,\n });\n }\n\n /**\n * Renders instance on a given context\n * @param {CanvasRenderingContext2D} ctx context to render instance on\n */\n render(ctx: CanvasRenderingContext2D) {\n this._transformDone = true;\n super.render(ctx);\n this._transformDone = false;\n }\n\n /**\n *\n * @private\n * @param {'toObject'|'toDatalessObject'} [method]\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @returns {FabricObject[]} serialized objects\n */\n __serializeObjects(\n method: 'toObject' | 'toDatalessObject',\n propertiesToInclude?: string[],\n ) {\n const _includeDefaultValues = this.includeDefaultValues;\n return this._objects\n .filter(function (obj) {\n return !obj.excludeFromExport;\n })\n .map(function (obj) {\n const originalDefaults = obj.includeDefaultValues;\n obj.includeDefaultValues = _includeDefaultValues;\n const data = obj[method || 'toObject'](propertiesToInclude);\n obj.includeDefaultValues = originalDefaults;\n // delete data.version;\n return data;\n });\n }\n\n /**\n * Returns object representation of an instance\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit<\n GroupProps & TClassProperties,\n keyof SerializedGroupProps\n >,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SerializedGroupProps {\n const layoutManager = this.layoutManager.toObject();\n\n return {\n ...super.toObject([\n 'subTargetCheck',\n 'interactive',\n ...propertiesToInclude,\n ]),\n ...(layoutManager.strategy !== 'fit-content' || this.includeDefaultValues\n ? { layoutManager }\n : {}),\n objects: this.__serializeObjects(\n 'toObject',\n propertiesToInclude as string[],\n ),\n };\n }\n\n toString() {\n return `#`;\n }\n\n dispose() {\n this.layoutManager.unsubscribeTargets({\n targets: this.getObjects(),\n target: this,\n });\n this._activeObjects = [];\n this.forEachObject((object) => {\n this._watchObject(false, object);\n object.dispose();\n });\n super.dispose();\n }\n\n /**\n * @private\n */\n _createSVGBgRect(reviver?: TSVGReviver) {\n if (!this.backgroundColor) {\n return '';\n }\n const fillStroke = Rect.prototype._toSVG.call(this);\n const commons = fillStroke.indexOf('COMMON_PARTS');\n fillStroke[commons] = 'for=\"group\" ';\n const markup = fillStroke.join('');\n return reviver ? reviver(markup) : markup;\n }\n\n /**\n * Returns svg representation of an instance\n * @param {TSVGReviver} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n _toSVG(reviver?: TSVGReviver) {\n const svgString = ['\\n'];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t\\t', this._objects[i].toSVG(reviver));\n }\n svgString.push('\\n');\n return svgString;\n }\n\n /**\n * Returns styles-string for svg-export, specific version for group\n * @return {String}\n */\n getSvgStyles(): string {\n const opacity =\n typeof this.opacity !== 'undefined' && this.opacity !== 1\n ? `opacity: ${this.opacity};`\n : '',\n visibility = this.visible ? '' : ' visibility: hidden;';\n return [opacity, this.getSvgFilter(), visibility].join('');\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {String} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const svgString = [];\n const bg = this._createSVGBgRect(reviver);\n bg && svgString.push('\\t', bg);\n for (let i = 0; i < this._objects.length; i++) {\n svgString.push('\\t', this._objects[i].toClipPathSVG(reviver));\n }\n return this._createBaseClipPathSVGMarkup(svgString, {\n reviver,\n });\n }\n\n /**\n * @todo support loading from svg\n * @private\n * @static\n * @memberOf Group\n * @param {Object} object Object to create a group from\n * @returns {Promise}\n */\n static fromObject>(\n { type, objects = [], layoutManager, ...options }: T,\n abortable?: Abortable,\n ) {\n return Promise.all([\n enlivenObjects(objects, abortable),\n enlivenObjectEnlivables(options, abortable),\n ]).then(([objects, hydratedOptions]) => {\n const group = new this(objects, {\n ...options,\n ...hydratedOptions,\n layoutManager: new NoopLayoutManager(),\n });\n if (layoutManager) {\n const layoutClass = classRegistry.getClass(\n layoutManager.type,\n );\n const strategyClass = classRegistry.getClass(\n layoutManager.strategy,\n );\n group.layoutManager = new layoutClass(new strategyClass());\n } else {\n group.layoutManager = new LayoutManager();\n }\n group.layoutManager.subscribeTargets({\n type: LAYOUT_TYPE_INITIALIZATION,\n target: group,\n targets: group.getObjects(),\n });\n group.setCoords();\n return group;\n });\n }\n}\n\nclassRegistry.setClass(Group);\n","import type { GroupProps } from '../../shapes/Group';\nimport { Group } from '../../shapes/Group';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\n\n/**\n * TODO experiment with different layout manager and svg results ( fixed fit content )\n * Groups SVG elements (usually those retrieved from SVG document)\n * @static\n * @param {FabricObject[]} elements FabricObject(s) parsed from svg, to group\n * @return {FabricObject | Group}\n */\nexport const groupSVGElements = (\n elements: FabricObject[],\n options?: Partial,\n) => {\n if (elements && elements.length === 1) {\n return elements[0];\n }\n return new Group(elements, options);\n};\n","import type { TSize } from '../../typedefs';\n\n/**\n * Finds the scale for the object source to fit inside the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to fit into destination\n */\nexport const findScaleToFit = (source: TSize, destination: TSize) =>\n Math.min(\n destination.width / source.width,\n destination.height / source.height,\n );\n\n/**\n * Finds the scale for the object source to cover entirely the object destination,\n * keeping aspect ratio intact.\n * respect the total allowed area for the cache.\n * @param {TSize} source natural unscaled size of the object\n * @param {TSize} destination natural unscaled size of the object\n * @return {Number} scale factor to apply to source to cover destination\n */\nexport const findScaleToCover = (source: TSize, destination: TSize) =>\n Math.max(\n destination.width / source.width,\n destination.height / source.height,\n );\n","import { reNum } from '../../parser/constants';\n\nconst commaWsp = `\\\\s*,?\\\\s*`;\n\n/**\n * p for param\n * using \"bad naming\" here because it makes the regex much easier to read\n * p is a number that is preceded by an arbitary number of spaces, maybe 0,\n * a comma or not, and then possibly more spaces or not.\n */\nconst p = `${commaWsp}(${reNum})`;\n\n// const reMoveToCommand = `(M) ?(?:${p}${p} ?)+`;\n\n// const reLineCommand = `(L) ?(?:${p}${p} ?)+`;\n\n// const reHorizontalLineCommand = `(H) ?(?:${p} ?)+`;\n\n// const reVerticalLineCommand = `(V) ?(?:${p} ?)+`;\n\n// const reClosePathCommand = String.raw`(Z)\\s*`;\n\n// const reCubicCurveCommand = `(C) ?(?:${p}${p}${p}${p}${p}${p} ?)+`;\n\n// const reCubicCurveShortcutCommand = `(S) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveCommand = `(Q) ?(?:${p}${p}${p}${p} ?)+`;\n\n// const reQuadraticCurveShortcutCommand = `(T) ?(?:${p}${p} ?)+`;\n\nexport const reArcCommandPoints = `${p}${p}${p}${commaWsp}([01])${commaWsp}([01])${p}${p}`;\n// const reArcCommand = `(A) ?(?:${reArcCommandPoints} ?)+`;\n\n// export const rePathCommandGroups =\n// `(?:(?:${reMoveToCommand})` +\n// `|(?:${reLineCommand})` +\n// `|(?:${reHorizontalLineCommand})` +\n// `|(?:${reVerticalLineCommand})` +\n// `|(?:${reClosePathCommand})` +\n// `|(?:${reCubicCurveCommand})` +\n// `|(?:${reCubicCurveShortcutCommand})` +\n// `|(?:${reQuadraticCurveCommand})` +\n// `|(?:${reQuadraticCurveShortcutCommand})` +\n// `|(?:${reArcCommand}))`;\n\nexport const rePathCommand = '[mzlhvcsqta][^mzlhvcsqta]*';\n","import { cache } from '../../cache';\nimport { config } from '../../config';\nimport { halfPI, PiBy180 } from '../../constants';\nimport type { TMat2D, TRadian, TRectBounds } from '../../typedefs';\nimport { cos } from '../misc/cos';\nimport { multiplyTransformMatrices, transformPoint } from '../misc/matrix';\nimport { sin } from '../misc/sin';\nimport { toFixed } from '../misc/toFixed';\nimport type {\n TCurveInfo,\n TComplexPathData,\n TParsedAbsoluteCubicCurveCommand,\n TPathSegmentInfo,\n TPointAngle,\n TSimpleParsedCommand,\n TSimplePathData,\n TPathSegmentCommandInfo,\n TComplexParsedCommand,\n TPathSegmentInfoCommon,\n TEndPathInfo,\n TParsedArcCommand,\n TComplexParsedCommandType,\n} from './typedefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { reArcCommandPoints, rePathCommand } from './regex';\nimport { reNum } from '../../parser/constants';\n\n/**\n * Commands that may be repeated\n */\nconst repeatedCommands: Record = {\n m: 'l',\n M: 'L',\n};\n\n/**\n * Convert an arc of a rotated ellipse to a Bezier Curve\n * @param {TRadian} theta1 start of the arc\n * @param {TRadian} theta2 end of the arc\n * @param cosTh cosine of the angle of rotation\n * @param sinTh sine of the angle of rotation\n * @param rx x-axis radius (before rotation)\n * @param ry y-axis radius (before rotation)\n * @param cx1 center x of the ellipse\n * @param cy1 center y of the ellipse\n * @param mT\n * @param fromX starting point of arc x\n * @param fromY starting point of arc y\n */\nconst segmentToBezier = (\n theta1: TRadian,\n theta2: TRadian,\n cosTh: number,\n sinTh: number,\n rx: number,\n ry: number,\n cx1: number,\n cy1: number,\n mT: number,\n fromX: number,\n fromY: number,\n): TParsedAbsoluteCubicCurveCommand => {\n const costh1 = cos(theta1),\n sinth1 = sin(theta1),\n costh2 = cos(theta2),\n sinth2 = sin(theta2),\n toX = cosTh * rx * costh2 - sinTh * ry * sinth2 + cx1,\n toY = sinTh * rx * costh2 + cosTh * ry * sinth2 + cy1,\n cp1X = fromX + mT * (-cosTh * rx * sinth1 - sinTh * ry * costh1),\n cp1Y = fromY + mT * (-sinTh * rx * sinth1 + cosTh * ry * costh1),\n cp2X = toX + mT * (cosTh * rx * sinth2 + sinTh * ry * costh2),\n cp2Y = toY + mT * (sinTh * rx * sinth2 - cosTh * ry * costh2);\n\n return ['C', cp1X, cp1Y, cp2X, cp2Y, toX, toY];\n};\n\n/**\n * Adapted from {@link http://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGPathDataParser.cpp}\n * by Andrea Bogazzi code is under MPL. if you don't have a copy of the license you can take it here\n * http://mozilla.org/MPL/2.0/\n * @param toX\n * @param toY\n * @param rx\n * @param ry\n * @param {number} large 0 or 1 flag\n * @param {number} sweep 0 or 1 flag\n * @param rotateX\n */\nconst arcToSegments = (\n toX: number,\n toY: number,\n rx: number,\n ry: number,\n large: number,\n sweep: number,\n rotateX: TRadian,\n): TParsedAbsoluteCubicCurveCommand[] => {\n if (rx === 0 || ry === 0) {\n return [];\n }\n let fromX = 0,\n fromY = 0,\n root = 0;\n const PI = Math.PI,\n theta = rotateX * PiBy180,\n sinTheta = sin(theta),\n cosTh = cos(theta),\n px = 0.5 * (-cosTh * toX - sinTheta * toY),\n py = 0.5 * (-cosTh * toY + sinTheta * toX),\n rx2 = rx ** 2,\n ry2 = ry ** 2,\n py2 = py ** 2,\n px2 = px ** 2,\n pl = rx2 * ry2 - rx2 * py2 - ry2 * px2;\n let _rx = Math.abs(rx);\n let _ry = Math.abs(ry);\n\n if (pl < 0) {\n const s = Math.sqrt(1 - pl / (rx2 * ry2));\n _rx *= s;\n _ry *= s;\n } else {\n root =\n (large === sweep ? -1.0 : 1.0) * Math.sqrt(pl / (rx2 * py2 + ry2 * px2));\n }\n\n const cx = (root * _rx * py) / _ry,\n cy = (-root * _ry * px) / _rx,\n cx1 = cosTh * cx - sinTheta * cy + toX * 0.5,\n cy1 = sinTheta * cx + cosTh * cy + toY * 0.5;\n let mTheta = calcVectorAngle(1, 0, (px - cx) / _rx, (py - cy) / _ry);\n let dtheta = calcVectorAngle(\n (px - cx) / _rx,\n (py - cy) / _ry,\n (-px - cx) / _rx,\n (-py - cy) / _ry,\n );\n\n if (sweep === 0 && dtheta > 0) {\n dtheta -= 2 * PI;\n } else if (sweep === 1 && dtheta < 0) {\n dtheta += 2 * PI;\n }\n\n // Convert into cubic bezier segments <= 90deg\n const segments = Math.ceil(Math.abs((dtheta / PI) * 2)),\n result = [],\n mDelta = dtheta / segments,\n mT =\n ((8 / 3) * Math.sin(mDelta / 4) * Math.sin(mDelta / 4)) /\n Math.sin(mDelta / 2);\n let th3 = mTheta + mDelta;\n\n for (let i = 0; i < segments; i++) {\n result[i] = segmentToBezier(\n mTheta,\n th3,\n cosTh,\n sinTheta,\n _rx,\n _ry,\n cx1,\n cy1,\n mT,\n fromX,\n fromY,\n );\n fromX = result[i][5];\n fromY = result[i][6];\n mTheta = th3;\n th3 += mDelta;\n }\n return result;\n};\n\n/**\n * @private\n * Calculate the angle between two vectors\n * @param ux u endpoint x\n * @param uy u endpoint y\n * @param vx v endpoint x\n * @param vy v endpoint y\n */\nconst calcVectorAngle = (\n ux: number,\n uy: number,\n vx: number,\n vy: number,\n): TRadian => {\n const ta = Math.atan2(uy, ux),\n tb = Math.atan2(vy, vx);\n if (tb >= ta) {\n return tb - ta;\n } else {\n return 2 * Math.PI - (ta - tb);\n }\n};\n\n// functions for the Cubic beizer\n// taken from: https://github.com/konvajs/konva/blob/7.0.5/src/shapes/Path.ts#L350\nconst CB1 = (t: number) => t ** 3;\nconst CB2 = (t: number) => 3 * t ** 2 * (1 - t);\nconst CB3 = (t: number) => 3 * t * (1 - t) ** 2;\nconst CB4 = (t: number) => (1 - t) ** 3;\n\n/**\n * Calculate bounding box of a cubic Bezier curve\n * Taken from http://jsbin.com/ivomiq/56/edit (no credits available)\n * TODO: can we normalize this with the starting points set at 0 and then translated the bbox?\n * @param {number} begx starting point\n * @param {number} begy\n * @param {number} cp1x first control point\n * @param {number} cp1y\n * @param {number} cp2x second control point\n * @param {number} cp2y\n * @param {number} endx end of bezier\n * @param {number} endy\n * @return {TRectBounds} the rectangular bounds\n */\nexport function getBoundsOfCurve(\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n): TRectBounds {\n let argsString: string;\n if (config.cachesBoundsOfCurve) {\n // eslint-disable-next-line\n argsString = [...arguments].join();\n if (cache.boundsOfCurveCache[argsString]) {\n return cache.boundsOfCurveCache[argsString];\n }\n }\n\n const sqrt = Math.sqrt,\n abs = Math.abs,\n tvalues = [],\n bounds: [[x: number, y: number], [x: number, y: number]] = [\n [0, 0],\n [0, 0],\n ];\n\n let b = 6 * begx - 12 * cp1x + 6 * cp2x;\n let a = -3 * begx + 9 * cp1x - 9 * cp2x + 3 * endx;\n let c = 3 * cp1x - 3 * begx;\n\n for (let i = 0; i < 2; ++i) {\n if (i > 0) {\n b = 6 * begy - 12 * cp1y + 6 * cp2y;\n a = -3 * begy + 9 * cp1y - 9 * cp2y + 3 * endy;\n c = 3 * cp1y - 3 * begy;\n }\n\n if (abs(a) < 1e-12) {\n if (abs(b) < 1e-12) {\n continue;\n }\n const t = -c / b;\n if (0 < t && t < 1) {\n tvalues.push(t);\n }\n continue;\n }\n const b2ac = b * b - 4 * c * a;\n if (b2ac < 0) {\n continue;\n }\n const sqrtb2ac = sqrt(b2ac);\n const t1 = (-b + sqrtb2ac) / (2 * a);\n if (0 < t1 && t1 < 1) {\n tvalues.push(t1);\n }\n const t2 = (-b - sqrtb2ac) / (2 * a);\n if (0 < t2 && t2 < 1) {\n tvalues.push(t2);\n }\n }\n\n let j = tvalues.length;\n const jlen = j;\n const iterator = getPointOnCubicBezierIterator(\n begx,\n begy,\n cp1x,\n cp1y,\n cp2x,\n cp2y,\n endx,\n endy,\n );\n while (j--) {\n const { x, y } = iterator(tvalues[j]);\n bounds[0][j] = x;\n bounds[1][j] = y;\n }\n\n bounds[0][jlen] = begx;\n bounds[1][jlen] = begy;\n bounds[0][jlen + 1] = endx;\n bounds[1][jlen + 1] = endy;\n const result: TRectBounds = [\n new Point(Math.min(...bounds[0]), Math.min(...bounds[1])),\n new Point(Math.max(...bounds[0]), Math.max(...bounds[1])),\n ];\n if (config.cachesBoundsOfCurve) {\n cache.boundsOfCurveCache[argsString!] = result;\n }\n return result;\n}\n\n/**\n * Converts arc to a bunch of cubic Bezier curves\n * @param {number} fx starting point x\n * @param {number} fy starting point y\n * @param {TParsedArcCommand} coords Arc command\n */\nexport const fromArcToBeziers = (\n fx: number,\n fy: number,\n [_, rx, ry, rot, large, sweep, tx, ty]: TParsedArcCommand,\n): TParsedAbsoluteCubicCurveCommand[] => {\n const segsNorm = arcToSegments(tx - fx, ty - fy, rx, ry, large, sweep, rot);\n\n for (let i = 0, len = segsNorm.length; i < len; i++) {\n segsNorm[i][1] += fx;\n segsNorm[i][2] += fy;\n segsNorm[i][3] += fx;\n segsNorm[i][4] += fy;\n segsNorm[i][5] += fx;\n segsNorm[i][6] += fy;\n }\n return segsNorm;\n};\n\n/**\n * This function takes a parsed SVG path and makes it simpler for fabricJS logic.\n * Simplification consist of:\n * - All commands converted to absolute (lowercase to uppercase)\n * - S converted to C\n * - T converted to Q\n * - A converted to C\n * @param {TComplexPathData} path the array of commands of a parsed SVG path for `Path`\n * @return {TSimplePathData} the simplified array of commands of a parsed SVG path for `Path`\n * TODO: figure out how to remove the type assertions in a nice way\n */\nexport const makePathSimpler = (path: TComplexPathData): TSimplePathData => {\n // x and y represent the last point of the path, AKA the previous command point.\n // we add them to each relative command to make it an absolute comment.\n // we also swap the v V h H with L, because are easier to transform.\n let x = 0,\n y = 0;\n // x1 and y1 represent the last point of the subpath. the subpath is started with\n // m or M command. When a z or Z command is drawn, x and y need to be resetted to\n // the last x1 and y1.\n let x1 = 0,\n y1 = 0;\n // previous will host the letter of the previous command, to handle S and T.\n // controlX and controlY will host the previous reflected control point\n const destinationPath: TSimplePathData = [];\n let previous,\n // placeholders\n controlX = 0,\n controlY = 0;\n for (const parsedCommand of path) {\n const current: TComplexParsedCommand = [...parsedCommand];\n let converted: TSimpleParsedCommand | undefined;\n switch (\n current[0] // first letter\n ) {\n case 'l': // lineto, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'L':\n x = current[1];\n y = current[2];\n converted = ['L', x, y];\n break;\n case 'h': // horizontal lineto, relative\n current[1] += x;\n // falls through\n case 'H':\n x = current[1];\n converted = ['L', x, y];\n break;\n case 'v': // vertical lineto, relative\n current[1] += y;\n // falls through\n case 'V':\n y = current[1];\n converted = ['L', x, y];\n break;\n case 'm': // moveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'M':\n x = current[1];\n y = current[2];\n x1 = current[1];\n y1 = current[2];\n converted = ['M', x, y];\n break;\n case 'c': // bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n current[5] += x;\n current[6] += y;\n // falls through\n case 'C':\n controlX = current[3];\n controlY = current[4];\n x = current[5];\n y = current[6];\n converted = ['C', current[1], current[2], controlX, controlY, x, y];\n break;\n case 's': // shorthand cubic bezierCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'S':\n // would be sScC but since we are swapping sSc for C, we check just that.\n if (previous === 'C') {\n // calculate reflection of previous control points\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a C, c, S, or s,\n // the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[3];\n y = current[4];\n converted = ['C', controlX, controlY, current[1], current[2], x, y];\n // converted[3] and converted[4] are NOW the second control point.\n // we keep it for the next reflection.\n controlX = converted[3];\n controlY = converted[4];\n break;\n case 'q': // quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n current[3] += x;\n current[4] += y;\n // falls through\n case 'Q':\n controlX = current[1];\n controlY = current[2];\n x = current[3];\n y = current[4];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 't': // shorthand quadraticCurveTo, relative\n current[1] += x;\n current[2] += y;\n // falls through\n case 'T':\n if (previous === 'Q') {\n // calculate reflection of previous control point\n controlX = 2 * x - controlX;\n controlY = 2 * y - controlY;\n } else {\n // If there is no previous command or if the previous command was not a Q, q, T or t,\n // assume the control point is coincident with the current point\n controlX = x;\n controlY = y;\n }\n x = current[1];\n y = current[2];\n converted = ['Q', controlX, controlY, x, y];\n break;\n case 'a':\n current[6] += x;\n current[7] += y;\n // falls through\n case 'A':\n fromArcToBeziers(x, y, current).forEach((b) => destinationPath.push(b));\n x = current[6];\n y = current[7];\n break;\n case 'z':\n case 'Z':\n x = x1;\n y = y1;\n converted = ['Z'];\n break;\n default:\n }\n if (converted) {\n destinationPath.push(converted);\n previous = converted[0];\n } else {\n previous = '';\n }\n }\n return destinationPath;\n};\n\n// todo verify if we can just use the point class here\n/**\n * Calc length from point x1,y1 to x2,y2\n * @param {number} x1 starting point x\n * @param {number} y1 starting point y\n * @param {number} x2 starting point x\n * @param {number} y2 starting point y\n * @return {number} length of segment\n */\nconst calcLineLength = (\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n): number => Math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2);\n\n/**\n * Get an iterator that takes a percentage and returns a point\n * @param {number} begx\n * @param {number} begy\n * @param {number} cp1x\n * @param {number} cp1y\n * @param {number} cp2x\n * @param {number} cp2y\n * @param {number} endx\n * @param {number} endy\n */\nconst getPointOnCubicBezierIterator =\n (\n begx: number,\n begy: number,\n cp1x: number,\n cp1y: number,\n cp2x: number,\n cp2y: number,\n endx: number,\n endy: number,\n ) =>\n (pct: number) => {\n const c1 = CB1(pct),\n c2 = CB2(pct),\n c3 = CB3(pct),\n c4 = CB4(pct);\n return new Point(\n endx * c1 + cp2x * c2 + cp1x * c3 + begx * c4,\n endy * c1 + cp2y * c2 + cp1y * c3 + begy * c4,\n );\n };\n\nconst QB1 = (t: number) => t ** 2;\nconst QB2 = (t: number) => 2 * t * (1 - t);\nconst QB3 = (t: number) => (1 - t) ** 2;\n\nconst getTangentCubicIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n p4x: number,\n p4y: number,\n ) =>\n (pct: number) => {\n const qb1 = QB1(pct),\n qb2 = QB2(pct),\n qb3 = QB3(pct),\n tangentX =\n 3 * (qb3 * (p2x - p1x) + qb2 * (p3x - p2x) + qb1 * (p4x - p3x)),\n tangentY =\n 3 * (qb3 * (p2y - p1y) + qb2 * (p3y - p2y) + qb1 * (p4y - p3y));\n return Math.atan2(tangentY, tangentX);\n };\n\nconst getPointOnQuadraticBezierIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const c1 = QB1(pct),\n c2 = QB2(pct),\n c3 = QB3(pct);\n return new Point(\n p3x * c1 + p2x * c2 + p1x * c3,\n p3y * c1 + p2y * c2 + p1y * c3,\n );\n };\n\nconst getTangentQuadraticIterator =\n (\n p1x: number,\n p1y: number,\n p2x: number,\n p2y: number,\n p3x: number,\n p3y: number,\n ) =>\n (pct: number) => {\n const invT = 1 - pct,\n tangentX = 2 * (invT * (p2x - p1x) + pct * (p3x - p2x)),\n tangentY = 2 * (invT * (p2y - p1y) + pct * (p3y - p2y));\n return Math.atan2(tangentY, tangentX);\n };\n\n// this will run over a path segment (a cubic or quadratic segment) and approximate it\n// with 100 segments. This will good enough to calculate the length of the curve\nconst pathIterator = (\n iterator: (pct: number) => Point,\n x1: number,\n y1: number,\n) => {\n let tempP = new Point(x1, y1),\n tmpLen = 0;\n for (let perc = 1; perc <= 100; perc += 1) {\n const p = iterator(perc / 100);\n tmpLen += calcLineLength(tempP.x, tempP.y, p.x, p.y);\n tempP = p;\n }\n return tmpLen;\n};\n\n/**\n * Given a pathInfo, and a distance in pixels, find the percentage from 0 to 1\n * that correspond to that pixels run over the path.\n * The percentage will be then used to find the correct point on the canvas for the path.\n * @param {Array} segInfo fabricJS collection of information on a parsed path\n * @param {number} distance from starting point, in pixels.\n * @return {TPointAngle} info object with x and y ( the point on canvas ) and angle, the tangent on that point;\n */\nconst findPercentageForDistance = (\n segInfo: TCurveInfo<'Q' | 'C'>,\n distance: number,\n): TPointAngle => {\n let perc = 0,\n tmpLen = 0,\n tempP: XY = { x: segInfo.x, y: segInfo.y },\n p: XY = { ...tempP },\n nextLen: number,\n nextStep = 0.01,\n lastPerc = 0;\n // nextStep > 0.0001 covers 0.00015625 that 1/64th of 1/100\n // the path\n const iterator = segInfo.iterator,\n angleFinder = segInfo.angleFinder;\n while (tmpLen < distance && nextStep > 0.0001) {\n p = iterator(perc);\n lastPerc = perc;\n nextLen = calcLineLength(tempP.x, tempP.y, p.x, p.y);\n // compare tmpLen each cycle with distance, decide next perc to test.\n if (nextLen + tmpLen > distance) {\n // we discard this step and we make smaller steps.\n perc -= nextStep;\n nextStep /= 2;\n } else {\n tempP = p;\n perc += nextStep;\n tmpLen += nextLen;\n }\n }\n return { ...p, angle: angleFinder(lastPerc) };\n};\n\n/**\n * Run over a parsed and simplified path and extract some information (length of each command and starting point)\n * @param {TSimplePathData} path parsed path commands\n * @return {TPathSegmentInfo[]} path commands information\n */\nexport const getPathSegmentsInfo = (\n path: TSimplePathData,\n): TPathSegmentInfo[] => {\n let totalLength = 0,\n //x2 and y2 are the coords of segment start\n //x1 and y1 are the coords of the current point\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n iterator,\n tempInfo: TPathSegmentInfo;\n const info: TPathSegmentInfo[] = [];\n for (const current of path) {\n const basicInfo: TPathSegmentInfoCommon = {\n x: x1,\n y: y1,\n command: current[0],\n length: 0,\n };\n switch (\n current[0] //first letter\n ) {\n case 'M':\n tempInfo = >basicInfo;\n tempInfo.x = x2 = x1 = current[1];\n tempInfo.y = y2 = y1 = current[2];\n break;\n case 'L':\n tempInfo = >basicInfo;\n tempInfo.length = calcLineLength(x1, y1, current[1], current[2]);\n x1 = current[1];\n y1 = current[2];\n break;\n case 'C':\n iterator = getPointOnCubicBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentCubicIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n current[5],\n current[6],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n\n x1 = current[5];\n y1 = current[6];\n break;\n case 'Q':\n iterator = getPointOnQuadraticBezierIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo = >basicInfo;\n tempInfo.iterator = iterator;\n tempInfo.angleFinder = getTangentQuadraticIterator(\n x1,\n y1,\n current[1],\n current[2],\n current[3],\n current[4],\n );\n tempInfo.length = pathIterator(iterator, x1, y1);\n x1 = current[3];\n y1 = current[4];\n break;\n case 'Z':\n // we add those in order to ease calculations later\n tempInfo = basicInfo;\n tempInfo.destX = x2;\n tempInfo.destY = y2;\n tempInfo.length = calcLineLength(x1, y1, x2, y2);\n x1 = x2;\n y1 = y2;\n break;\n }\n totalLength += tempInfo.length;\n info.push(tempInfo);\n }\n info.push({ length: totalLength, x: x1, y: y1 });\n return info;\n};\n\n/**\n * Get the point on the path that is distance along the path\n * @param path\n * @param distance\n * @param infos\n */\nexport const getPointOnPath = (\n path: TSimplePathData,\n distance: number,\n infos: TPathSegmentInfo[] = getPathSegmentsInfo(path),\n): TPointAngle | undefined => {\n let i = 0;\n while (distance - infos[i].length > 0 && i < infos.length - 2) {\n distance -= infos[i].length;\n i++;\n }\n const segInfo = infos[i],\n segPercent = distance / segInfo.length,\n segment = path[i];\n\n switch (segInfo.command) {\n case 'M':\n return { x: segInfo.x, y: segInfo.y, angle: 0 };\n case 'Z':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segInfo.destX, segInfo.destY),\n segPercent,\n ),\n angle: Math.atan2(segInfo.destY - segInfo.y, segInfo.destX - segInfo.x),\n };\n case 'L':\n return {\n ...new Point(segInfo.x, segInfo.y).lerp(\n new Point(segment[1]!, segment[2]!),\n segPercent,\n ),\n angle: Math.atan2(segment[2]! - segInfo.y, segment[1]! - segInfo.x),\n };\n case 'C':\n return findPercentageForDistance(segInfo, distance);\n case 'Q':\n return findPercentageForDistance(segInfo, distance);\n default:\n // throw Error('Invalid command');\n }\n};\n\nconst rePathCmdAll = new RegExp(rePathCommand, 'gi');\nconst regExpArcCommandPoints = new RegExp(reArcCommandPoints, 'g');\nconst reMyNum = new RegExp(reNum, 'gi');\nconst commandLengths = {\n m: 2,\n l: 2,\n h: 1,\n v: 1,\n c: 6,\n s: 4,\n q: 4,\n t: 2,\n a: 7,\n} as const;\n/**\n *\n * @param {string} pathString\n * @return {TComplexPathData} An array of SVG path commands\n * @example Usage\n * parsePath('M 3 4 Q 3 5 2 1 4 0 Q 9 12 2 1 4 0') === [\n * ['M', 3, 4],\n * ['Q', 3, 5, 2, 1, 4, 0],\n * ['Q', 9, 12, 2, 1, 4, 0],\n * ];\n */\nexport const parsePath = (pathString: string): TComplexPathData => {\n const chain: TComplexPathData = [];\n const all = pathString.match(rePathCmdAll) ?? [];\n for (const matchStr of all) {\n // take match string and save the first letter as the command\n const commandLetter = matchStr[0] as TComplexParsedCommandType;\n // in case of Z we have very little to do\n if (commandLetter === 'z' || commandLetter === 'Z') {\n chain.push([commandLetter]);\n continue;\n }\n const commandLength =\n commandLengths[\n commandLetter.toLowerCase() as keyof typeof commandLengths\n ];\n\n let paramArr = [];\n if (commandLetter === 'a' || commandLetter === 'A') {\n // the arc command ha some peculariaties that requires a special regex other than numbers\n // it is possible to avoid using a space between the sweep and large arc flags, making them either\n // 00, 01, 10 or 11, making them identical to a plain number for the regex reMyNum\n // reset the regexp\n regExpArcCommandPoints.lastIndex = 0;\n for (let out = null; (out = regExpArcCommandPoints.exec(matchStr)); ) {\n paramArr.push(...out.slice(1));\n }\n } else {\n paramArr = matchStr.match(reMyNum) || [];\n }\n\n // inspect the length of paramArr, if is longer than commandLength\n // we are dealing with repeated commands\n for (let i = 0; i < paramArr.length; i += commandLength) {\n const newCommand = new Array(commandLength) as TComplexParsedCommand;\n const transformedCommand = repeatedCommands[commandLetter];\n newCommand[0] =\n i > 0 && transformedCommand ? transformedCommand : commandLetter;\n for (let j = 0; j < commandLength; j++) {\n newCommand[j + 1] = parseFloat(paramArr[i + j]);\n }\n chain.push(newCommand);\n }\n }\n return chain;\n};\n\n/**\n *\n * Converts points to a smooth SVG path\n * @param {XY[]} points Array of points\n * @param {number} [correction] Apply a correction to the path (usually we use `width / 1000`). If value is undefined 0 is used as the correction value.\n * @return {(string|number)[][]} An array of SVG path commands\n */\nexport const getSmoothPathFromPoints = (\n points: Point[],\n correction = 0,\n): TSimplePathData => {\n let p1 = new Point(points[0]),\n p2 = new Point(points[1]),\n multSignX = 1,\n multSignY = 0;\n const path: TSimplePathData = [],\n len = points.length,\n manyPoints = len > 2;\n\n if (manyPoints) {\n multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1;\n multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1;\n }\n path.push([\n 'M',\n p1.x - multSignX * correction,\n p1.y - multSignY * correction,\n ]);\n let i;\n for (i = 1; i < len; i++) {\n if (!p1.eq(p2)) {\n const midPoint = p1.midPointFrom(p2);\n // p1 is our bezier control point\n // midpoint is our endpoint\n // start point is p(i-1) value.\n path.push(['Q', p1.x, p1.y, midPoint.x, midPoint.y]);\n }\n p1 = points[i];\n if (i + 1 < points.length) {\n p2 = points[i + 1];\n }\n }\n if (manyPoints) {\n multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1;\n multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1;\n }\n path.push([\n 'L',\n p1.x + multSignX * correction,\n p1.y + multSignY * correction,\n ]);\n return path;\n};\n\n/**\n * Transform a path by transforming each segment.\n * it has to be a simplified path or it won't work.\n * WARNING: this depends from pathOffset for correct operation\n * @param {TSimplePathData} path fabricJS parsed and simplified path commands\n * @param {TMat2D} transform matrix that represent the transformation\n * @param {Point} [pathOffset] `Path.pathOffset`\n * @returns {TSimplePathData} the transformed path\n */\nexport const transformPath = (\n path: TSimplePathData,\n transform: TMat2D,\n pathOffset: Point,\n): TSimplePathData => {\n if (pathOffset) {\n transform = multiplyTransformMatrices(transform, [\n 1,\n 0,\n 0,\n 1,\n -pathOffset.x,\n -pathOffset.y,\n ]);\n }\n return path.map((pathSegment) => {\n const newSegment: TSimpleParsedCommand = [...pathSegment];\n for (let i = 1; i < pathSegment.length - 1; i += 2) {\n // TODO: is there a way to get around casting to any?\n const { x, y } = transformPoint(\n {\n x: pathSegment[i] as number,\n y: pathSegment[i + 1] as number,\n },\n transform,\n );\n newSegment[i] = x;\n newSegment[i + 1] = y;\n }\n return newSegment;\n });\n};\n\n/**\n * Returns an array of path commands to create a regular polygon\n * @param {number} numVertexes\n * @param {number} radius\n * @returns {TSimplePathData} An array of SVG path commands\n */\nexport const getRegularPolygonPath = (\n numVertexes: number,\n radius: number,\n): TSimplePathData => {\n const interiorAngle = (Math.PI * 2) / numVertexes;\n // rotationAdjustment rotates the path by 1/2 the interior angle so that the polygon always has a flat side on the bottom\n // This isn't strictly necessary, but it's how we tend to think of and expect polygons to be drawn\n let rotationAdjustment = -halfPI;\n if (numVertexes % 2 === 0) {\n rotationAdjustment += interiorAngle / 2;\n }\n const d = new Array(numVertexes + 1);\n for (let i = 0; i < numVertexes; i++) {\n const rad = i * interiorAngle + rotationAdjustment;\n const { x, y } = new Point(cos(rad), sin(rad)).scalarMultiply(radius);\n d[i] = [i === 0 ? 'M' : 'L', x, y];\n }\n d[numVertexes] = ['Z'];\n return d;\n};\n\n/**\n * Join path commands to go back to svg format\n * @param {TSimplePathData} pathData fabricJS parsed path commands\n * @param {number} fractionDigits number of fraction digits to \"leave\"\n * @return {String} joined path 'M 0 0 L 20 30'\n */\nexport const joinPath = (pathData: TSimplePathData, fractionDigits?: number) =>\n pathData\n .map((segment) => {\n return segment\n .map((arg, i) => {\n if (i === 0) return arg;\n return fractionDigits === undefined\n ? arg\n : toFixed(arg, fractionDigits);\n })\n .join(' ');\n })\n .join(' ');\n","// TODO this file needs to go away, cross browser style support is not fabricjs domain.\n\n/**\n * wrapper for setting element's style\n * @param {HTMLElement} element\n * @param {Object | string} styles\n */\nexport function setStyle(\n element: HTMLElement,\n styles: string | Record,\n) {\n const elementStyle = element.style;\n if (!elementStyle || !styles) {\n return;\n } else if (typeof styles === 'string') {\n elementStyle.cssText += ';' + styles;\n } else {\n Object.entries(styles).forEach(([property, value]) =>\n elementStyle.setProperty(property, value),\n );\n }\n}\n","import type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { sendObjectToPlane } from './planeChange';\nimport { Group } from '../../shapes/Group';\n/**\n * Merges 2 clip paths into one visually equal clip path\n *\n * **IMPORTANT**:\\\n * Does **NOT** clone the arguments, clone them proir if necessary.\n *\n * Creates a wrapper (group) that contains one clip path and is clipped by the other so content is kept where both overlap.\n * Use this method if both the clip paths may have nested clip paths of their own, so assigning one to the other's clip path property is not possible.\n *\n * In order to handle the `inverted` property we follow logic described in the following cases:\\\n * **(1)** both clip paths are inverted - the clip paths pass the inverted prop to the wrapper and loose it themselves.\\\n * **(2)** one is inverted and the other isn't - the wrapper shouldn't become inverted and the inverted clip path must clip the non inverted one to produce an identical visual effect.\\\n * **(3)** both clip paths are not inverted - wrapper and clip paths remain unchanged.\n *\n * @memberOf fabric.util\n * @param {fabric.Object} c1\n * @param {fabric.Object} c2\n * @returns {fabric.Object} merged clip path\n */\nexport const mergeClipPaths = (c1: FabricObject, c2: FabricObject) => {\n let a = c1,\n b = c2;\n if (a.inverted && !b.inverted) {\n // case (2)\n a = c2;\n b = c1;\n }\n // `b` becomes `a`'s clip path so we transform `b` to `a` coordinate plane\n sendObjectToPlane(b, b.group?.calcTransformMatrix(), a.calcTransformMatrix());\n // assign the `inverted` prop to the wrapping group\n const inverted = a.inverted && b.inverted;\n if (inverted) {\n // case (1)\n a.inverted = b.inverted = false;\n }\n return new Group([a], { clipPath: b, inverted });\n};\n","/**\n * Returns random number between 2 specified ones.\n * @param {Number} min lower limit\n * @param {Number} max upper limit\n * @return {Number} random value (between min and max)\n */\nexport const getRandomInt = (min: number, max: number): number =>\n Math.floor(Math.random() * (max - min + 1)) + min;\n","import { getFabricWindow } from '../../env';\nimport { noop } from '../../constants';\nimport type { Abortable } from '../../typedefs';\nimport { SignalAbortedError } from './console';\n\ntype requestOptions = Abortable & {\n onComplete?: (xhr: XMLHttpRequest) => void;\n};\n\n/**\n * Cross-browser abstraction for sending XMLHttpRequest\n * @deprecated this has to go away, we can use a modern browser method to do the same.\n * @param {String} url URL to send XMLHttpRequest to\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} options.onComplete Callback to invoke when request is completed\n * @return {XMLHttpRequest} request\n */\n\nexport function request(url: string, options: requestOptions = {}) {\n const onComplete = options.onComplete || noop,\n xhr = new (getFabricWindow().XMLHttpRequest)(),\n signal = options.signal,\n abort = function () {\n xhr.abort();\n },\n removeListener = function () {\n signal && signal.removeEventListener('abort', abort);\n xhr.onerror = xhr.ontimeout = noop;\n };\n\n if (signal && signal.aborted) {\n throw new SignalAbortedError('request');\n } else if (signal) {\n signal.addEventListener('abort', abort, { once: true });\n }\n\n /** @ignore */\n xhr.onreadystatechange = function () {\n if (xhr.readyState === 4) {\n removeListener();\n onComplete(xhr);\n xhr.onreadystatechange = noop;\n }\n };\n\n xhr.onerror = xhr.ontimeout = removeListener;\n\n xhr.open('get', url, true);\n\n xhr.send();\n return xhr;\n}\n","import { CENTER, SCALE_X, SCALE_Y } from '../constants';\nimport type { FabricImage } from '../shapes/Image';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { qrDecompose } from './misc/matrix';\n\ntype FabricObjectWithTransformMatrix = FabricObject & {\n transformMatrix?: TMat2D;\n};\n\n/**\n * This function is an helper for svg import. it decompose the transformMatrix\n * and assign properties to object.\n * untransformed coordinates\n * @private\n */\nconst _assignTransformMatrixProps = (\n object: FabricObjectWithTransformMatrix,\n) => {\n if (object.transformMatrix) {\n const { scaleX, scaleY, angle, skewX } = qrDecompose(\n object.transformMatrix,\n );\n object.flipX = false;\n object.flipY = false;\n object.set(SCALE_X, scaleX);\n object.set(SCALE_Y, scaleY);\n object.angle = angle;\n object.skewX = skewX;\n object.skewY = 0;\n }\n};\n\n/**\n * This function is an helper for svg import. it removes the transform matrix\n * and set to object properties that fabricjs can handle\n * @private\n * @param {Object} preserveAspectRatioOptions\n */\nexport const removeTransformMatrixForSvgParsing = (\n object: FabricObjectWithTransformMatrix,\n preserveAspectRatioOptions?: any,\n) => {\n let center = object._findCenterFromElement();\n if (object.transformMatrix) {\n _assignTransformMatrixProps(object);\n center = center.transform(object.transformMatrix);\n }\n delete object.transformMatrix;\n if (preserveAspectRatioOptions) {\n object.scaleX *= preserveAspectRatioOptions.scaleX;\n object.scaleY *= preserveAspectRatioOptions.scaleY;\n (object as FabricImage).cropX = preserveAspectRatioOptions.cropX;\n (object as FabricImage).cropY = preserveAspectRatioOptions.cropY;\n center.x += preserveAspectRatioOptions.offsetLeft;\n center.y += preserveAspectRatioOptions.offsetTop;\n object.width = preserveAspectRatioOptions.width;\n object.height = preserveAspectRatioOptions.height;\n }\n object.setPositionByOrigin(center, CENTER, CENTER);\n};\n","import { getEnv, getFabricDocument } from '../../env';\nimport type { TSize } from '../../typedefs';\nimport { createCanvasElement, setStyle } from '../../util';\nimport type { CSSDimensions } from './util';\nimport { makeElementUnselectable, setCSSDimensions } from './util';\nimport type { CanvasItem } from './StaticCanvasDOMManager';\nimport { StaticCanvasDOMManager } from './StaticCanvasDOMManager';\nimport { setCanvasDimensions } from './util';\nimport { NONE } from '../../constants';\n\nexport class CanvasDOMManager extends StaticCanvasDOMManager {\n upper: CanvasItem;\n container: HTMLDivElement;\n\n constructor(\n arg0?: string | HTMLCanvasElement,\n {\n allowTouchScrolling = false,\n containerClass = '',\n }: {\n allowTouchScrolling?: boolean;\n /**\n * @deprecated here only for backward compatibility\n */\n containerClass?: string;\n } = {},\n ) {\n super(arg0);\n const { el: lowerCanvasEl } = this.lower;\n const upperCanvasEl = this.createUpperCanvas();\n this.upper = { el: upperCanvasEl, ctx: upperCanvasEl.getContext('2d')! };\n this.applyCanvasStyle(lowerCanvasEl, {\n allowTouchScrolling,\n });\n this.applyCanvasStyle(upperCanvasEl, {\n allowTouchScrolling,\n styles: {\n position: 'absolute',\n left: '0',\n top: '0',\n },\n });\n const container = this.createContainerElement();\n container.classList.add(containerClass);\n if (lowerCanvasEl.parentNode) {\n lowerCanvasEl.parentNode.replaceChild(container, lowerCanvasEl);\n }\n container.append(lowerCanvasEl, upperCanvasEl);\n this.container = container;\n }\n\n protected createUpperCanvas() {\n const { el: lowerCanvasEl } = this.lower;\n const el = createCanvasElement();\n // we assign the same classname of the lowerCanvas\n el.className = lowerCanvasEl.className;\n // but then we remove the lower-canvas specific className\n el.classList.remove('lower-canvas');\n // we add the specific upper-canvas class\n el.classList.add('upper-canvas');\n el.setAttribute('data-fabric', 'top');\n el.style.cssText = lowerCanvasEl.style.cssText;\n el.setAttribute('draggable', 'true');\n return el;\n }\n\n protected createContainerElement() {\n const container = getFabricDocument().createElement('div');\n container.setAttribute('data-fabric', 'wrapper');\n setStyle(container, {\n position: 'relative',\n });\n makeElementUnselectable(container);\n return container;\n }\n\n /**\n * @private\n * @param {HTMLCanvasElement} element canvas element to apply styles on\n */\n protected applyCanvasStyle(\n element: HTMLCanvasElement,\n options: {\n allowTouchScrolling?: boolean;\n styles?: Record;\n },\n ) {\n const { styles, allowTouchScrolling } = options;\n setStyle(element, {\n ...styles,\n 'touch-action': allowTouchScrolling ? 'manipulation' : NONE,\n });\n makeElementUnselectable(element);\n }\n\n setDimensions(size: TSize, retinaScaling: number) {\n super.setDimensions(size, retinaScaling);\n const { el, ctx } = this.upper;\n setCanvasDimensions(el, ctx, size, retinaScaling);\n }\n\n setCSSDimensions(size: Partial): void {\n super.setCSSDimensions(size);\n setCSSDimensions(this.upper.el, size);\n setCSSDimensions(this.container, size);\n }\n\n cleanupDOM(size: TSize) {\n const container = this.container,\n { el: lowerCanvasEl } = this.lower,\n { el: upperCanvasEl } = this.upper;\n super.cleanupDOM(size);\n container.removeChild(upperCanvasEl);\n container.removeChild(lowerCanvasEl);\n if (container.parentNode) {\n container.parentNode.replaceChild(lowerCanvasEl, container);\n }\n }\n\n dispose() {\n super.dispose();\n getEnv().dispose(this.upper.el);\n // @ts-expect-error disposing\n delete this.upper;\n // @ts-expect-error disposing\n delete this.container;\n }\n}\n","import type { ModifierKey, TOptionalModifierKey } from '../EventTypeDefs';\nimport type { TOptions } from '../typedefs';\nimport type { StaticCanvasOptions } from './StaticCanvasOptions';\n\nexport interface CanvasTransformOptions {\n /**\n * When true, objects can be transformed by one side (unproportionately)\n * when dragged on the corners that normally would not do that.\n * @type Boolean\n * @default\n * @since fabric 4.0 // changed name and default value\n */\n uniformScaling: boolean;\n\n /**\n * Indicates which key switches uniform scaling.\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * totally wrong named. this sounds like `uniform scaling`\n * if Canvas.uniformScaling is true, pressing this will set it to false\n * and viceversa.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n uniScaleKey: TOptionalModifierKey;\n\n /**\n * When true, objects use center point as the origin of scale transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredScaling: boolean;\n\n /**\n * When true, objects use center point as the origin of rotate transformation.\n * Backwards incompatibility note: This property replaces \"centerTransform\" (Boolean).\n * @since 1.3.4\n * @type Boolean\n * @default\n */\n centeredRotation: boolean;\n\n /**\n * Indicates which key enable centered Transform\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n centeredKey: TOptionalModifierKey;\n\n /**\n * Indicates which key enable alternate action on corner\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled feature disabled.\n * @since 1.6.2\n * @type ModifierKey\n * @default\n */\n altActionKey: TOptionalModifierKey;\n}\n\nexport interface CanvasSelectionOptions {\n /**\n * Indicates whether group selection should be enabled\n * @type Boolean\n * @default\n */\n selection: boolean;\n\n /**\n * Indicates which key or keys enable multiple click selection\n * Pass value as a string or array of strings\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * If `null` or empty or containing any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.2\n * @type ModifierKey|ModifierKey[]\n * @default\n */\n selectionKey: TOptionalModifierKey | ModifierKey[];\n\n /**\n * Indicates which key enable alternative selection\n * in case of target overlapping with active object\n * values: 'altKey', 'shiftKey', 'ctrlKey'.\n * For a series of reason that come from the general expectations on how\n * things should work, this feature works only for preserveObjectStacking true.\n * If `null` or 'none' or any other string that is not a modifier key\n * feature is disabled.\n * @since 1.6.5\n * @type null|ModifierKey\n * @default\n */\n altSelectionKey: TOptionalModifierKey;\n\n /**\n * Color of selection\n * @type String\n * @default\n */\n selectionColor: string;\n\n /**\n * Default dash array pattern\n * If not empty the selection border is dashed\n * @type Array\n */\n selectionDashArray: number[];\n\n /**\n * Color of the border of selection (usually slightly darker than color of selection itself)\n * @type String\n * @default\n */\n selectionBorderColor: string;\n\n /**\n * Width of a line used in object/group selection\n * @type Number\n * @default\n */\n selectionLineWidth: number;\n\n /**\n * Select only shapes that are fully contained in the dragged selection rectangle.\n * @type Boolean\n * @default\n */\n selectionFullyContained: boolean;\n}\n\nexport interface CanvasCursorOptions {\n /**\n * Default cursor value used when hovering over an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n hoverCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used when moving an object on canvas\n * @type CSSStyleDeclaration['cursor']\n * @default move\n */\n moveCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Default cursor value used for the entire canvas\n * @type String\n * @default default\n */\n defaultCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used during free drawing\n * @type String\n * @default crosshair\n */\n freeDrawingCursor: CSSStyleDeclaration['cursor'];\n\n /**\n * Cursor value used for disabled elements ( corners with disabled action )\n * @type String\n * @since 2.0.0\n * @default not-allowed\n */\n notAllowedCursor: CSSStyleDeclaration['cursor'];\n}\n\nexport interface TargetFindOptions {\n /**\n * When true, object detection happens on per-pixel basis rather than on per-bounding-box\n * @type Boolean\n * @default\n */\n perPixelTargetFind: boolean;\n\n /**\n * Number of pixels around target pixel to tolerate (consider active) during object detection\n * @type Number\n * @default\n */\n targetFindTolerance: number;\n\n /**\n * When true, target detection is skipped. Target detection will return always undefined.\n * click selection won't work anymore, events will fire with no targets.\n * if something is selected before setting it to true, it will be deselected at the first click.\n * area selection will still work. check the `selection` property too.\n * if you deactivate both, you should look into staticCanvas.\n * @type Boolean\n * @default\n */\n skipTargetFind: boolean;\n}\n\nexport interface CanvasEventsOptions {\n /**\n * Indicates if the right click on canvas can output the context menu or not\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n stopContextMenu: boolean;\n\n /**\n * Indicates if the canvas can fire right click events\n * @type Boolean\n * @since 1.6.5\n * @default\n */\n fireRightClick: boolean;\n\n /**\n * Indicates if the canvas can fire middle click events\n * @type Boolean\n * @since 1.7.8\n * @default\n */\n fireMiddleClick: boolean;\n\n /**\n * When the option is enabled, PointerEvent is used instead of TPointerEvent.\n * @type Boolean\n * @default\n */\n enablePointerEvents: boolean;\n}\n\nexport interface CanvasOptions\n extends StaticCanvasOptions,\n CanvasTransformOptions,\n CanvasSelectionOptions,\n CanvasCursorOptions,\n TargetFindOptions,\n CanvasEventsOptions {\n /**\n * Default element class that's given to wrapper (div) element of canvas\n * @type String\n * @default\n * @deprecated customize {@link CanvasDOMManager} instead or access {@link elements} directly\n */\n containerClass: string;\n\n /**\n * Indicates whether objects should remain in current stack position when selected.\n * When false objects are brought to top and rendered as part of the selection group\n * @type Boolean\n * @default\n */\n preserveObjectStacking: boolean;\n}\n\nexport type TCanvasOptions = TOptions;\n\nexport const canvasDefaults: TOptions = {\n uniformScaling: true,\n uniScaleKey: 'shiftKey',\n centeredScaling: false,\n centeredRotation: false,\n centeredKey: 'altKey',\n altActionKey: 'shiftKey',\n\n selection: true,\n selectionKey: 'shiftKey',\n selectionColor: 'rgba(100, 100, 255, 0.3)',\n selectionDashArray: [],\n selectionBorderColor: 'rgba(255, 255, 255, 0.3)',\n selectionLineWidth: 1,\n selectionFullyContained: false,\n\n hoverCursor: 'move',\n moveCursor: 'move',\n defaultCursor: 'default',\n freeDrawingCursor: 'crosshair',\n notAllowedCursor: 'not-allowed',\n\n perPixelTargetFind: false,\n targetFindTolerance: 0,\n skipTargetFind: false,\n\n stopContextMenu: false,\n fireRightClick: false,\n fireMiddleClick: false,\n enablePointerEvents: false,\n\n containerClass: 'canvas-container',\n\n preserveObjectStacking: false,\n};\n","import { dragHandler } from '../controls/drag';\nimport { getActionFromCorner } from '../controls/util';\nimport { Point } from '../Point';\nimport { FabricObject } from '../shapes/Object/FabricObject';\nimport type {\n CanvasEvents,\n ModifierKey,\n TOptionalModifierKey,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport {\n addTransformToObject,\n saveObjectTransform,\n} from '../util/misc/objectTransforms';\nimport type { TCanvasSizeOptions } from './StaticCanvas';\nimport { StaticCanvas } from './StaticCanvas';\nimport { isCollection } from '../Collection';\nimport { isTransparent } from '../util/misc/isTransparent';\nimport type {\n TMat2D,\n TOriginX,\n TOriginY,\n TSize,\n TSVGReviver,\n} from '../typedefs';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { getPointer, isTouchEvent } from '../util/dom_event';\nimport type { IText } from '../shapes/IText/IText';\nimport type { BaseBrush } from '../brushes/BaseBrush';\nimport { pick } from '../util/misc/pick';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { cos, createCanvasElement, sin } from '../util';\nimport { CanvasDOMManager } from './DOMManagers/CanvasDOMManager';\nimport {\n BOTTOM,\n CENTER,\n LEFT,\n MODIFIED,\n RESIZING,\n RIGHT,\n ROTATE,\n SCALE,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CanvasOptions } from './CanvasOptions';\nimport { canvasDefaults } from './CanvasOptions';\nimport { Intersection } from '../Intersection';\nimport { isActiveSelection } from '../util/typeAssertions';\n\n/**\n * Canvas class\n * @class Canvas\n * @extends StaticCanvas\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#canvas}\n *\n * @fires object:modified at the end of a transform\n * @fires object:rotating while an object is being rotated from the control\n * @fires object:scaling while an object is being scaled by controls\n * @fires object:moving while an object is being dragged\n * @fires object:skewing while an object is being skewed from the controls\n *\n * @fires before:transform before a transform is is started\n * @fires before:selection:cleared\n * @fires selection:cleared\n * @fires selection:updated\n * @fires selection:created\n *\n * @fires path:created after a drawing operation ends and the path is added\n * @fires mouse:down\n * @fires mouse:move\n * @fires mouse:up\n * @fires mouse:down:before on mouse down, before the inner fabric logic runs\n * @fires mouse:move:before on mouse move, before the inner fabric logic runs\n * @fires mouse:up:before on mouse up, before the inner fabric logic runs\n * @fires mouse:over\n * @fires mouse:out\n * @fires mouse:dblclick whenever a native dbl click event fires on the canvas.\n *\n * @fires dragover\n * @fires dragenter\n * @fires dragleave\n * @fires drag:enter object drag enter\n * @fires drag:leave object drag leave\n * @fires drop:before before drop event. Prepare for the drop event (same native event).\n * @fires drop\n * @fires drop:after after drop event. Run logic on canvas after event has been accepted/declined (same native event).\n * @example\n * let a: fabric.Object, b: fabric.Object;\n * let flag = false;\n * canvas.add(a, b);\n * a.on('drop:before', opt => {\n * // we want a to accept the drop even though it's below b in the stack\n * flag = this.canDrop(opt.e);\n * });\n * b.canDrop = function(e) {\n * !flag && this.draggableTextDelegate.canDrop(e);\n * }\n * b.on('dragover', opt => b.set('fill', opt.dropTarget === b ? 'pink' : 'black'));\n * a.on('drop', opt => {\n * opt.e.defaultPrevented // drop occurred\n * opt.didDrop // drop occurred on canvas\n * opt.target // drop target\n * opt.target !== a && a.set('text', 'I lost');\n * });\n * canvas.on('drop:after', opt => {\n * // inform user who won\n * if(!opt.e.defaultPrevented) {\n * // no winners\n * }\n * else if(!opt.didDrop) {\n * // my objects didn't win, some other lucky object\n * }\n * else {\n * // we have a winner it's opt.target!!\n * }\n * })\n *\n * @fires after:render at the end of the render process, receives the context in the callback\n * @fires before:render at start the render process, receives the context in the callback\n *\n * @fires contextmenu:before\n * @fires contextmenu\n * @example\n * let handler;\n * targets.forEach(target => {\n * target.on('contextmenu:before', opt => {\n * // decide which target should handle the event before canvas hijacks it\n * if (someCaseHappens && opt.targets.includes(target)) {\n * handler = target;\n * }\n * });\n * target.on('contextmenu', opt => {\n * // do something fantastic\n * });\n * });\n * canvas.on('contextmenu', opt => {\n * if (!handler) {\n * // no one takes responsibility, it's always left to me\n * // let's show them how it's done!\n * }\n * });\n *\n */\nexport class SelectableCanvas\n extends StaticCanvas\n implements Omit\n{\n declare _objects: FabricObject[];\n\n // transform config\n declare uniformScaling: boolean;\n declare uniScaleKey: TOptionalModifierKey;\n declare centeredScaling: boolean;\n declare centeredRotation: boolean;\n declare centeredKey: TOptionalModifierKey;\n declare altActionKey: TOptionalModifierKey;\n\n // selection config\n declare selection: boolean;\n declare selectionKey: TOptionalModifierKey | ModifierKey[];\n declare altSelectionKey: TOptionalModifierKey;\n declare selectionColor: string;\n declare selectionDashArray: number[];\n declare selectionBorderColor: string;\n declare selectionLineWidth: number;\n declare selectionFullyContained: boolean;\n\n // cursors\n declare hoverCursor: CSSStyleDeclaration['cursor'];\n declare moveCursor: CSSStyleDeclaration['cursor'];\n declare defaultCursor: CSSStyleDeclaration['cursor'];\n declare freeDrawingCursor: CSSStyleDeclaration['cursor'];\n declare notAllowedCursor: CSSStyleDeclaration['cursor'];\n\n declare containerClass: string;\n\n // target find config\n declare perPixelTargetFind: boolean;\n declare targetFindTolerance: number;\n declare skipTargetFind: boolean;\n\n /**\n * When true, mouse events on canvas (mousedown/mousemove/mouseup) result in free drawing.\n * After mousedown, mousemove creates a shape,\n * and then mouseup finalizes it and adds an instance of `fabric.Path` onto canvas.\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-4#free_drawing}\n * @type Boolean\n * @default\n */\n declare isDrawingMode: boolean;\n\n declare preserveObjectStacking: boolean;\n\n // event config\n declare stopContextMenu: boolean;\n declare fireRightClick: boolean;\n declare fireMiddleClick: boolean;\n\n /**\n * Keep track of the subTargets for Mouse Events, ordered bottom up from innermost nested subTarget\n * @type FabricObject[]\n */\n targets: FabricObject[] = [];\n\n /**\n * Keep track of the hovered target\n * @type FabricObject | null\n * @private\n */\n declare _hoveredTarget?: FabricObject;\n\n /**\n * hold the list of nested targets hovered\n * @type FabricObject[]\n * @private\n */\n _hoveredTargets: FabricObject[] = [];\n\n /**\n * hold the list of objects to render\n * @type FabricObject[]\n * @private\n */\n _objectsToRender?: FabricObject[];\n\n /**\n * hold a reference to a data structure that contains information\n * on the current on going transform\n * @type\n * @private\n */\n _currentTransform: Transform | null = null;\n\n /**\n * hold a reference to a data structure used to track the selection\n * box on canvas drag\n * on the current on going transform\n * x, y, deltaX and deltaY are in scene plane\n * @type\n * @private\n */\n protected _groupSelector: {\n x: number;\n y: number;\n deltaX: number;\n deltaY: number;\n } | null = null;\n\n /**\n * internal flag used to understand if the context top requires a cleanup\n * in case this is true, the contextTop will be cleared at the next render\n * @type boolean\n * @private\n */\n contextTopDirty = false;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _absolutePointer holds a reference to the pointer in fabricCanvas/design coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _absolutePointer?: Point;\n\n /**\n * During a mouse event we may need the pointer multiple times in multiple functions.\n * _pointer holds a reference to the pointer in html coordinates that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * We do this because there are some HTML DOM inspection functions to get the actual pointer coordinates\n * @type {Point}\n */\n protected declare _pointer?: Point;\n\n /**\n * During a mouse event we may need the target multiple times in multiple functions.\n * _target holds a reference to the target that is valid for the event\n * lifespan. Every fabricJS mouse event create and delete the cache every time\n * @type {FabricObject}\n */\n protected declare _target?: FabricObject;\n\n static ownDefaults = canvasDefaults;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...SelectableCanvas.ownDefaults };\n }\n\n declare elements: CanvasDOMManager;\n get upperCanvasEl() {\n return this.elements.upper?.el;\n }\n get contextTop() {\n return this.elements.upper?.ctx;\n }\n get wrapperEl() {\n return this.elements.container;\n }\n private declare pixelFindCanvasEl: HTMLCanvasElement;\n private declare pixelFindContext: CanvasRenderingContext2D;\n\n protected declare _isCurrentlyDrawing: boolean;\n declare freeDrawingBrush?: BaseBrush;\n declare _activeObject?: FabricObject;\n\n protected initElements(el?: string | HTMLCanvasElement) {\n this.elements = new CanvasDOMManager(el, {\n allowTouchScrolling: this.allowTouchScrolling,\n containerClass: this.containerClass,\n });\n this._createCacheCanvas();\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was added\n */\n _onObjectAdded(obj: FabricObject) {\n this._objectsToRender = undefined;\n super._onObjectAdded(obj);\n }\n\n /**\n * @private\n * @param {FabricObject} obj Object that was removed\n */\n _onObjectRemoved(obj: FabricObject) {\n this._objectsToRender = undefined;\n // removing active object should fire \"selection:cleared\" events\n if (obj === this._activeObject) {\n this.fire('before:selection:cleared', { deselected: [obj] });\n this._discardActiveObject();\n this.fire('selection:cleared', { deselected: [obj] });\n obj.fire('deselected', {\n target: obj,\n });\n }\n if (obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n super._onObjectRemoved(obj);\n }\n\n _onStackOrderChanged() {\n this._objectsToRender = undefined;\n super._onStackOrderChanged();\n }\n\n /**\n * Divides objects in two groups, one to render immediately\n * and one to render as activeGroup.\n * @return {Array} objects to render immediately and pushes the other in the activeGroup.\n */\n _chooseObjectsToRender(): FabricObject[] {\n const activeObject = this._activeObject;\n return !this.preserveObjectStacking && activeObject\n ? this._objects\n .filter((object) => !object.group && object !== activeObject)\n .concat(activeObject)\n : this._objects;\n }\n\n /**\n * Renders both the top canvas and the secondary container canvas.\n */\n renderAll() {\n this.cancelRequestedRender();\n if (this.destroyed) {\n return;\n }\n if (this.contextTopDirty && !this._groupSelector && !this.isDrawingMode) {\n this.clearContext(this.contextTop);\n this.contextTopDirty = false;\n }\n if (this.hasLostContext) {\n this.renderTopLayer(this.contextTop);\n this.hasLostContext = false;\n }\n !this._objectsToRender &&\n (this._objectsToRender = this._chooseObjectsToRender());\n this.renderCanvas(this.getContext(), this._objectsToRender);\n }\n\n /**\n * text selection is rendered by the active text instance during the rendering cycle\n */\n renderTopLayer(ctx: CanvasRenderingContext2D): void {\n ctx.save();\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this.freeDrawingBrush && this.freeDrawingBrush._render();\n this.contextTopDirty = true;\n }\n // we render the top context - last object\n if (this.selection && this._groupSelector) {\n this._drawSelection(ctx);\n this.contextTopDirty = true;\n }\n ctx.restore();\n }\n\n /**\n * Method to render only the top canvas.\n * Also used to render the group selection box.\n * Does not render text selection.\n */\n renderTop() {\n const ctx = this.contextTop;\n this.clearContext(ctx);\n this.renderTopLayer(ctx);\n // todo: how do i know if the after:render is for the top or normal contex?\n this.fire('after:render', { ctx });\n }\n\n /**\n * Set the canvas tolerance value for pixel taret find.\n * Use only integer numbers.\n * @private\n */\n setTargetFindTolerance(value: number) {\n value = Math.round(value);\n this.targetFindTolerance = value;\n const retina = this.getRetinaScaling();\n const size = Math.ceil((value * 2 + 1) * retina);\n this.pixelFindCanvasEl.width = this.pixelFindCanvasEl.height = size;\n this.pixelFindContext.scale(retina, retina);\n }\n\n /**\n * Returns true if object is transparent at a certain location\n * Clarification: this is `is target transparent at location X or are controls there`\n * @TODO this seems dumb that we treat controls with transparency. we can find controls\n * programmatically without painting them, the cache canvas optimization is always valid\n * @param {FabricObject} target Object to check\n * @param {Number} x Left coordinate in viewport space\n * @param {Number} y Top coordinate in viewport space\n * @return {Boolean}\n */\n isTargetTransparent(target: FabricObject, x: number, y: number): boolean {\n const tolerance = this.targetFindTolerance;\n const ctx = this.pixelFindContext;\n this.clearContext(ctx);\n ctx.save();\n ctx.translate(-x + tolerance, -y + tolerance);\n ctx.transform(...this.viewportTransform);\n const selectionBgc = target.selectionBackgroundColor;\n target.selectionBackgroundColor = '';\n target.render(ctx);\n target.selectionBackgroundColor = selectionBgc;\n ctx.restore();\n // our canvas is square, and made around tolerance.\n // so tolerance in this case also represent the center of the canvas.\n const enhancedTolerance = Math.round(tolerance * this.getRetinaScaling());\n return isTransparent(\n ctx,\n enhancedTolerance,\n enhancedTolerance,\n enhancedTolerance,\n );\n }\n\n /**\n * takes an event and determines if selection key has been pressed\n * @private\n * @param {TPointerEvent} e Event object\n */\n _isSelectionKeyPressed(e: TPointerEvent): boolean {\n const sKey = this.selectionKey;\n if (!sKey) {\n return false;\n }\n if (Array.isArray(sKey)) {\n return !!sKey.find((key) => !!key && e[key] === true);\n } else {\n return e[sKey];\n }\n }\n\n /**\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target\n */\n _shouldClearSelection(\n e: TPointerEvent,\n target?: FabricObject,\n ): target is undefined {\n const activeObjects = this.getActiveObjects(),\n activeObject = this._activeObject;\n\n return !!(\n !target ||\n (target &&\n activeObject &&\n activeObjects.length > 1 &&\n activeObjects.indexOf(target) === -1 &&\n activeObject !== target &&\n !this._isSelectionKeyPressed(e)) ||\n (target && !target.evented) ||\n (target && !target.selectable && activeObject && activeObject !== target)\n );\n }\n\n /**\n * This method will take in consideration a modifier key pressed and the control we are\n * about to drag, and try to guess the anchor point ( origin ) of the transormation.\n * This should be really in the realm of controls, and we should remove specific code for legacy\n * embedded actions.\n * @TODO this probably deserve discussion/rediscovery and change/refactor\n * @private\n * @deprecated\n * @param {FabricObject} target\n * @param {string} action\n * @param {boolean} altKey\n * @returns {boolean} true if the transformation should be centered\n */\n private _shouldCenterTransform(\n target: FabricObject,\n action: string,\n modifierKeyPressed: boolean,\n ) {\n if (!target) {\n return;\n }\n\n let centerTransform;\n\n if (\n action === SCALE ||\n action === SCALE_X ||\n action === SCALE_Y ||\n action === RESIZING\n ) {\n centerTransform = this.centeredScaling || target.centeredScaling;\n } else if (action === ROTATE) {\n centerTransform = this.centeredRotation || target.centeredRotation;\n }\n\n return centerTransform ? !modifierKeyPressed : modifierKeyPressed;\n }\n\n /**\n * Given the control clicked, determine the origin of the transform.\n * This is bad because controls can totally have custom names\n * should disappear before release 4.0\n * @private\n * @deprecated\n */\n _getOriginFromCorner(\n target: FabricObject,\n controlName: string,\n ): { x: TOriginX; y: TOriginY } {\n const origin = {\n x: target.originX,\n y: target.originY,\n };\n\n if (!controlName) {\n return origin;\n }\n\n // is a left control ?\n if (['ml', 'tl', 'bl'].includes(controlName)) {\n origin.x = RIGHT;\n // is a right control ?\n } else if (['mr', 'tr', 'br'].includes(controlName)) {\n origin.x = LEFT;\n }\n // is a top control ?\n if (['tl', 'mt', 'tr'].includes(controlName)) {\n origin.y = BOTTOM;\n // is a bottom control ?\n } else if (['bl', 'mb', 'br'].includes(controlName)) {\n origin.y = TOP;\n }\n return origin;\n }\n\n /**\n * @private\n * @param {Event} e Event object\n * @param {FabricObject} target\n * @param {boolean} [alreadySelected] pass true to setup the active control\n */\n _setupCurrentTransform(\n e: TPointerEvent,\n target: FabricObject,\n alreadySelected: boolean,\n ): void {\n const pointer = target.group\n ? // transform pointer to target's containing coordinate plane\n sendPointToPlane(\n this.getScenePoint(e),\n undefined,\n target.group.calcTransformMatrix(),\n )\n : this.getScenePoint(e);\n const { key: corner = '', control } = target.getActiveControl() || {},\n actionHandler =\n alreadySelected && control\n ? control.getActionHandler(e, target, control)?.bind(control)\n : dragHandler,\n action = getActionFromCorner(alreadySelected, corner, e, target),\n altKey = e[this.centeredKey as ModifierKey],\n origin = this._shouldCenterTransform(target, action, altKey)\n ? ({ x: CENTER, y: CENTER } as const)\n : this._getOriginFromCorner(target, corner),\n /**\n * relative to target's containing coordinate plane\n * both agree on every point\n **/\n transform: Transform = {\n target: target,\n action,\n actionHandler,\n actionPerformed: false,\n corner,\n scaleX: target.scaleX,\n scaleY: target.scaleY,\n skewX: target.skewX,\n skewY: target.skewY,\n offsetX: pointer.x - target.left,\n offsetY: pointer.y - target.top,\n originX: origin.x,\n originY: origin.y,\n ex: pointer.x,\n ey: pointer.y,\n lastX: pointer.x,\n lastY: pointer.y,\n theta: degreesToRadians(target.angle),\n width: target.width,\n height: target.height,\n shiftKey: e.shiftKey,\n altKey,\n original: {\n ...saveObjectTransform(target),\n originX: origin.x,\n originY: origin.y,\n },\n };\n\n this._currentTransform = transform;\n\n this.fire('before:transform', {\n e,\n transform,\n });\n }\n\n /**\n * Set the cursor type of the canvas element\n * @param {String} value Cursor type of the canvas element.\n * @see http://www.w3.org/TR/css3-ui/#cursor\n */\n setCursor(value: CSSStyleDeclaration['cursor']): void {\n this.upperCanvasEl.style.cursor = value;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx to draw the selection on\n */\n _drawSelection(ctx: CanvasRenderingContext2D): void {\n const { x, y, deltaX, deltaY } = this._groupSelector!,\n start = new Point(x, y).transform(this.viewportTransform),\n extent = new Point(x + deltaX, y + deltaY).transform(\n this.viewportTransform,\n ),\n strokeOffset = this.selectionLineWidth / 2;\n let minX = Math.min(start.x, extent.x),\n minY = Math.min(start.y, extent.y),\n maxX = Math.max(start.x, extent.x),\n maxY = Math.max(start.y, extent.y);\n\n if (this.selectionColor) {\n ctx.fillStyle = this.selectionColor;\n ctx.fillRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n if (!this.selectionLineWidth || !this.selectionBorderColor) {\n return;\n }\n ctx.lineWidth = this.selectionLineWidth;\n ctx.strokeStyle = this.selectionBorderColor;\n\n minX += strokeOffset;\n minY += strokeOffset;\n maxX -= strokeOffset;\n maxY -= strokeOffset;\n // selection border\n // @TODO: is _setLineDash still necessary on modern canvas?\n FabricObject.prototype._setLineDash.call(\n this,\n ctx,\n this.selectionDashArray,\n );\n ctx.strokeRect(minX, minY, maxX - minX, maxY - minY);\n }\n\n /**\n * Method that determines what object we are clicking on\n * 11/09/2018 TODO: would be cool if findTarget could discern between being a full target\n * or the outside part of the corner.\n * @param {Event} e mouse event\n * @return {FabricObject | null} the target found\n */\n findTarget(e: TPointerEvent): FabricObject | undefined {\n if (this.skipTargetFind) {\n return undefined;\n }\n\n const pointer = this.getViewportPoint(e),\n activeObject = this._activeObject,\n aObjects = this.getActiveObjects();\n\n this.targets = [];\n\n if (activeObject && aObjects.length >= 1) {\n if (activeObject.findControl(pointer, isTouchEvent(e))) {\n // if we hit the corner of the active object, let's return that.\n return activeObject;\n } else if (\n aObjects.length > 1 &&\n // check pointer is over active selection and possibly perform `subTargetCheck`\n this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active selection does not select sub targets like normal groups\n return activeObject;\n } else if (\n activeObject === this.searchPossibleTargets([activeObject], pointer)\n ) {\n // active object is not an active selection\n if (!this.preserveObjectStacking) {\n return activeObject;\n } else {\n const subTargets = this.targets;\n this.targets = [];\n const target = this.searchPossibleTargets(this._objects, pointer);\n if (\n e[this.altSelectionKey as ModifierKey] &&\n target &&\n target !== activeObject\n ) {\n // alt selection: select active object even though it is not the top most target\n // restore targets\n this.targets = subTargets;\n return activeObject;\n }\n return target;\n }\n }\n }\n\n return this.searchPossibleTargets(this._objects, pointer);\n }\n\n /**\n * Checks if the point is inside the object selection area including padding\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point in scene coordinates\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n private _pointIsInObjectSelectionArea(obj: FabricObject, point: Point) {\n // getCoords will already take care of group de-nesting\n let coords = obj.getCoords();\n const viewportZoom = this.getZoom();\n const padding = obj.padding / viewportZoom;\n if (padding) {\n const [tl, tr, br, bl] = coords;\n // what is the angle of the object?\n // we could use getTotalAngle, but is way easier to look at it\n // from how coords are oriented, since if something went wrong\n // at least we are consistent.\n const angleRadians = Math.atan2(tr.y - tl.y, tr.x - tl.x),\n cosP = cos(angleRadians) * padding,\n sinP = sin(angleRadians) * padding,\n cosPSinP = cosP + sinP,\n cosPMinusSinP = cosP - sinP;\n\n coords = [\n new Point(tl.x - cosPMinusSinP, tl.y - cosPSinP),\n new Point(tr.x + cosPSinP, tr.y - cosPMinusSinP),\n new Point(br.x + cosPMinusSinP, br.y + cosPSinP),\n new Point(bl.x - cosPSinP, bl.y + cosPMinusSinP),\n ];\n // in case of padding we calculate the new coords on the fly.\n // otherwise we have to maintain 2 sets of coordinates for everything.\n // we can reiterate on storing them.\n // if this is slow, for now the semplification is large and doesn't impact\n // rendering.\n // the idea behind this is that outside target check we don't need ot know\n // where those coords are\n }\n return Intersection.isPointInPolygon(point, coords);\n }\n\n /**\n * Checks point is inside the object selection condition. Either area with padding\n * or over pixels if perPixelTargetFind is enabled\n * @param {FabricObject} obj Object to test against\n * @param {Object} [pointer] point from viewport.\n * @return {Boolean} true if point is contained within an area of given object\n * @private\n */\n _checkTarget(obj: FabricObject, pointer: Point): boolean {\n if (\n obj &&\n obj.visible &&\n obj.evented &&\n this._pointIsInObjectSelectionArea(\n obj,\n sendPointToPlane(pointer, undefined, this.viewportTransform),\n )\n ) {\n if (\n (this.perPixelTargetFind || obj.perPixelTargetFind) &&\n !(obj as unknown as IText).isEditing\n ) {\n if (!this.isTargetTransparent(obj, pointer.x, pointer.y)) {\n return true;\n }\n } else {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Internal Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @param {Array} [objects] objects array to look into\n * @param {Object} [pointer] x,y object of point coordinates we want to check.\n * @return {FabricObject} **top most object from given `objects`** that contains pointer\n * @private\n */\n _searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n // Cache all targets where their bounding box contains point.\n let i = objects.length;\n // Do not check for currently grouped objects, since we check the parent group itself.\n // until we call this function specifically to search inside the activeGroup\n while (i--) {\n const target = objects[i];\n if (this._checkTarget(target, pointer)) {\n if (isCollection(target) && target.subTargetCheck) {\n const subTarget = this._searchPossibleTargets(\n target._objects as FabricObject[],\n pointer,\n );\n subTarget && this.targets.push(subTarget);\n }\n return target;\n }\n }\n }\n\n /**\n * Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted\n * @see {@link _searchPossibleTargets}\n * @param {FabricObject[]} [objects] objects array to look into\n * @param {Point} [pointer] coordinates from viewport to check.\n * @return {FabricObject} **top most object on screen** that contains pointer\n */\n searchPossibleTargets(\n objects: FabricObject[],\n pointer: Point,\n ): FabricObject | undefined {\n const target = this._searchPossibleTargets(objects, pointer);\n\n // if we found something in this.targets, and the group is interactive, return the innermost subTarget\n // that is still interactive\n // TODO: reverify why interactive. the target should be returned always, but selected only\n // if interactive.\n if (\n target &&\n isCollection(target) &&\n target.interactive &&\n this.targets[0]\n ) {\n /** targets[0] is the innermost nested target, but it could be inside non interactive groups and so not a selection target */\n const targets = this.targets;\n for (let i = targets.length - 1; i > 0; i--) {\n const t = targets[i];\n if (!(isCollection(t) && t.interactive)) {\n // one of the subtargets was not interactive. that is the last subtarget we can return.\n // we can't dig more deep;\n return t;\n }\n }\n return targets[0];\n }\n\n return target;\n }\n\n /**\n * @returns point existing in the same plane as the {@link HTMLCanvasElement},\n * `(0, 0)` being the top left corner of the {@link HTMLCanvasElement}.\n * This means that changes to the {@link viewportTransform} do not change the values of the point\n * and it remains unchanged from the viewer's perspective.\n *\n * @example\n * const scenePoint = sendPointToPlane(\n * this.getViewportPoint(e),\n * undefined,\n * canvas.viewportTransform\n * );\n *\n */\n getViewportPoint(e: TPointerEvent) {\n if (this._pointer) {\n return this._pointer;\n }\n return this.getPointer(e, true);\n }\n\n /**\n * @returns point existing in the scene (the same plane as the plane {@link FabricObject#getCenterPoint} exists in).\n * This means that changes to the {@link viewportTransform} do not change the values of the point,\n * however, from the viewer's perspective, the point is changed.\n *\n * @example\n * const viewportPoint = sendPointToPlane(\n * this.getScenePoint(e),\n * canvas.viewportTransform\n * );\n *\n */\n getScenePoint(e: TPointerEvent) {\n if (this._absolutePointer) {\n return this._absolutePointer;\n }\n return this.getPointer(e);\n }\n\n /**\n * Returns pointer relative to canvas.\n *\n * @deprecated This method is deprecated since v6 to protect you from misuse.\n * Use {@link getViewportPoint} or {@link getScenePoint} instead.\n *\n * @param {Event} e\n * @param {Boolean} [fromViewport] whether to return the point from the viewport or in the scene\n * @return {Point}\n */\n getPointer(e: TPointerEvent, fromViewport = false): Point {\n const upperCanvasEl = this.upperCanvasEl,\n bounds = upperCanvasEl.getBoundingClientRect();\n let pointer = getPointer(e),\n boundsWidth = bounds.width || 0,\n boundsHeight = bounds.height || 0;\n\n if (!boundsWidth || !boundsHeight) {\n if (TOP in bounds && BOTTOM in bounds) {\n boundsHeight = Math.abs(bounds.top - bounds.bottom);\n }\n if (RIGHT in bounds && LEFT in bounds) {\n boundsWidth = Math.abs(bounds.right - bounds.left);\n }\n }\n\n this.calcOffset();\n pointer.x = pointer.x - this._offset.left;\n pointer.y = pointer.y - this._offset.top;\n if (!fromViewport) {\n pointer = sendPointToPlane(pointer, undefined, this.viewportTransform);\n }\n\n const retinaScaling = this.getRetinaScaling();\n if (retinaScaling !== 1) {\n pointer.x /= retinaScaling;\n pointer.y /= retinaScaling;\n }\n\n // If bounds are not available (i.e. not visible), do not apply scale.\n const cssScale =\n boundsWidth === 0 || boundsHeight === 0\n ? new Point(1, 1)\n : new Point(\n upperCanvasEl.width / boundsWidth,\n upperCanvasEl.height / boundsHeight,\n );\n\n return pointer.multiply(cssScale);\n }\n\n /**\n * Internal use only\n * @protected\n */\n protected _setDimensionsImpl(\n dimensions: TSize,\n options?: TCanvasSizeOptions,\n ) {\n // @ts-expect-error this method exists in the subclass - should be moved or declared as abstract\n this._resetTransformEventData();\n super._setDimensionsImpl(dimensions, options);\n if (this._isCurrentlyDrawing) {\n this.freeDrawingBrush &&\n this.freeDrawingBrush._setBrushStyles(this.contextTop);\n }\n }\n\n protected _createCacheCanvas() {\n this.pixelFindCanvasEl = createCanvasElement();\n this.pixelFindContext = this.pixelFindCanvasEl.getContext('2d', {\n willReadFrequently: true,\n })!;\n this.setTargetFindTolerance(this.targetFindTolerance);\n }\n\n /**\n * Returns context of top canvas where interactions are drawn\n * @returns {CanvasRenderingContext2D}\n */\n getTopContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns context of canvas where object selection is drawn\n * @alias\n * @return {CanvasRenderingContext2D}\n */\n getSelectionContext(): CanvasRenderingContext2D {\n return this.elements.upper.ctx;\n }\n\n /**\n * Returns <canvas> element on which object selection is drawn\n * @return {HTMLCanvasElement}\n */\n getSelectionElement(): HTMLCanvasElement {\n return this.elements.upper.el;\n }\n\n /**\n * Returns currently active object\n * @return {FabricObject | null} active object\n */\n getActiveObject(): FabricObject | undefined {\n return this._activeObject;\n }\n\n /**\n * Returns an array with the current selected objects\n * @return {FabricObject[]} active objects array\n */\n getActiveObjects(): FabricObject[] {\n const active = this._activeObject;\n return isActiveSelection(active)\n ? active.getObjects()\n : active\n ? [active]\n : [];\n }\n\n /**\n * @private\n * Compares the old activeObject with the current one and fires correct events\n * @param {FabricObject[]} oldObjects old activeObject\n * @param {TPointerEvent} e mouse event triggering the selection events\n */\n _fireSelectionEvents(oldObjects: FabricObject[], e?: TPointerEvent) {\n let somethingChanged = false,\n invalidate = false;\n const objects = this.getActiveObjects(),\n added: FabricObject[] = [],\n removed: FabricObject[] = [];\n\n oldObjects.forEach((target) => {\n if (!objects.includes(target)) {\n somethingChanged = true;\n target.fire('deselected', {\n e,\n target,\n });\n removed.push(target);\n }\n });\n\n objects.forEach((target) => {\n if (!oldObjects.includes(target)) {\n somethingChanged = true;\n target.fire('selected', {\n e,\n target,\n });\n added.push(target);\n }\n });\n\n if (oldObjects.length > 0 && objects.length > 0) {\n invalidate = true;\n somethingChanged &&\n this.fire('selection:updated', {\n e,\n selected: added,\n deselected: removed,\n });\n } else if (objects.length > 0) {\n invalidate = true;\n this.fire('selection:created', {\n e,\n selected: added,\n });\n } else if (oldObjects.length > 0) {\n invalidate = true;\n this.fire('selection:cleared', {\n e,\n deselected: removed,\n });\n }\n invalidate && (this._objectsToRender = undefined);\n }\n\n /**\n * Sets given object as the only active object on canvas\n * @param {FabricObject} object Object to set as an active one\n * @param {TPointerEvent} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n setActiveObject(object: FabricObject, e?: TPointerEvent) {\n // we can't inline this, since _setActiveObject will change what getActiveObjects returns\n const currentActives = this.getActiveObjects();\n const selected = this._setActiveObject(object, e);\n this._fireSelectionEvents(currentActives, e);\n return selected;\n }\n\n /**\n * This is supposed to be equivalent to setActiveObject but without firing\n * any event. There is commitment to have this stay this way.\n * This is the functional part of setActiveObject.\n * @param {Object} object to set as active\n * @param {Event} [e] Event (passed along when firing \"object:selected\")\n * @return {Boolean} true if the object has been selected\n */\n _setActiveObject(object: FabricObject, e?: TPointerEvent) {\n const prevActiveObject = this._activeObject;\n if (prevActiveObject === object) {\n return false;\n }\n // after calling this._discardActiveObject, this,_activeObject could be undefined\n if (!this._discardActiveObject(e, object) && this._activeObject) {\n // refused to deselect\n return false;\n }\n if (object.onSelect({ e })) {\n return false;\n }\n\n this._activeObject = object;\n\n if (isActiveSelection(object) && prevActiveObject !== object) {\n object.set('canvas', this);\n }\n object.setCoords();\n\n return true;\n }\n\n /**\n * This is supposed to be equivalent to discardActiveObject but without firing\n * any selection events ( can still fire object transformation events ). There is commitment to have this stay this way.\n * This is the functional part of discardActiveObject.\n * @param {Event} [e] Event (passed along when firing \"object:deselected\")\n * @param {Object} object the next object to set as active, reason why we are discarding this\n * @return {Boolean} true if the active object has been discarded\n */\n _discardActiveObject(\n e?: TPointerEvent,\n object?: FabricObject,\n ): this is { _activeObject: undefined } {\n const obj = this._activeObject;\n if (obj) {\n // onDeselect return TRUE to cancel selection;\n if (obj.onDeselect({ e, object })) {\n return false;\n }\n if (this._currentTransform && this._currentTransform.target === obj) {\n this.endCurrentTransform(e);\n }\n if (isActiveSelection(obj) && obj === this._hoveredTarget) {\n this._hoveredTarget = undefined;\n }\n this._activeObject = undefined;\n return true;\n }\n return false;\n }\n\n /**\n * Discards currently active object and fire events. If the function is called by fabric\n * as a consequence of a mouse event, the event is passed as a parameter and\n * sent to the fire function for the custom events. When used as a method the\n * e param does not have any application.\n * @param {event} e\n * @return {Boolean} true if the active object has been discarded\n */\n discardActiveObject(e?: TPointerEvent): this is { _activeObject: undefined } {\n const currentActives = this.getActiveObjects(),\n activeObject = this.getActiveObject();\n if (currentActives.length) {\n this.fire('before:selection:cleared', {\n e,\n deselected: [activeObject!],\n });\n }\n const discarded = this._discardActiveObject(e);\n this._fireSelectionEvents(currentActives, e);\n return discarded;\n }\n\n /**\n * End the current transform.\n * You don't usually need to call this method unless you are interrupting a user initiated transform\n * because of some other event ( a press of key combination, or something that block the user UX )\n * @param {Event} [e] send the mouse event that generate the finalize down, so it can be used in the event\n */\n endCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform;\n this._finalizeCurrentTransform(e);\n if (transform && transform.target) {\n // this could probably go inside _finalizeCurrentTransform\n transform.target.isMoving = false;\n }\n this._currentTransform = null;\n }\n\n /**\n * @private\n * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event\n */\n _finalizeCurrentTransform(e?: TPointerEvent) {\n const transform = this._currentTransform!,\n target = transform.target,\n options = {\n e,\n target,\n transform,\n action: transform.action,\n };\n\n if (target._scaling) {\n target._scaling = false;\n }\n\n target.setCoords();\n\n if (transform.actionPerformed) {\n this.fire('object:modified', options);\n target.fire(MODIFIED, options);\n }\n }\n\n /**\n * Sets viewport transformation of this canvas instance\n * @param {Array} vpt a Canvas 2D API transform matrix\n */\n setViewportTransform(vpt: TMat2D) {\n super.setViewportTransform(vpt);\n const activeObject = this._activeObject;\n if (activeObject) {\n activeObject.setCoords();\n }\n }\n\n /**\n * @override clears active selection ref and interactive canvas elements and contexts\n */\n destroy() {\n // dispose of active selection\n const activeObject = this._activeObject;\n if (isActiveSelection(activeObject)) {\n activeObject.removeAll();\n activeObject.dispose();\n }\n\n delete this._activeObject;\n\n super.destroy();\n\n // free resources\n\n // pixel find canvas\n // @ts-expect-error disposing\n this.pixelFindContext = null;\n // @ts-expect-error disposing\n this.pixelFindCanvasEl = undefined;\n }\n\n /**\n * Clears all contexts (background, main, top) of an instance\n */\n clear() {\n // discard active object and fire events\n this.discardActiveObject();\n // make sure we clear the active object in case it refused to be discarded\n this._activeObject = undefined;\n this.clearContext(this.contextTop);\n super.clear();\n }\n\n /**\n * Draws objects' controls (borders/controls)\n * @param {CanvasRenderingContext2D} ctx Context to render controls on\n */\n drawControls(ctx: CanvasRenderingContext2D) {\n const activeObject = this._activeObject;\n\n if (activeObject) {\n activeObject._renderControls(ctx);\n }\n }\n\n /**\n * @private\n */\n protected _toObject(\n instance: FabricObject,\n methodName: 'toObject' | 'toDatalessObject',\n propertiesToInclude: string[],\n ): Record {\n // If the object is part of the current selection group, it should\n // be transformed appropriately\n // i.e. it should be serialised as it would appear if the selection group\n // were to be destroyed.\n const originalProperties = this._realizeGroupTransformOnObject(instance),\n object = super._toObject(instance, methodName, propertiesToInclude);\n //Undo the damage we did by changing all of its properties\n instance.set(originalProperties);\n return object;\n }\n\n /**\n * Realizes an object's group transformation on it\n * @private\n * @param {FabricObject} [instance] the object to transform (gets mutated)\n * @returns the original values of instance which were changed\n */\n private _realizeGroupTransformOnObject(\n instance: FabricObject,\n ): Partial {\n const { group } = instance;\n if (group && isActiveSelection(group) && this._activeObject === group) {\n const layoutProps = [\n 'angle',\n 'flipX',\n 'flipY',\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n ] as (keyof typeof instance)[];\n const originalValues = pick(instance, layoutProps);\n addTransformToObject(instance, group.calcOwnMatrix());\n return originalValues;\n } else {\n return {};\n }\n }\n\n /**\n * @private\n */\n _setSVGObject(\n markup: string[],\n instance: FabricObject,\n reviver?: TSVGReviver,\n ) {\n // If the object is in a selection group, simulate what would happen to that\n // object when the group is deselected\n const originalProperties = this._realizeGroupTransformOnObject(instance);\n super._setSVGObject(markup, instance, reviver);\n instance.set(originalProperties);\n }\n}\n","import type { TPointerEvent } from '../EventTypeDefs';\nimport type { ITextBehavior } from '../shapes/IText/ITextBehavior';\nimport { removeFromArray } from '../util/internals/removeFromArray';\nimport type { Canvas } from './Canvas';\n\n/**\n * In charge of synchronizing all interactive text instances of a canvas\n */\nexport class TextEditingManager {\n private targets: ITextBehavior[] = [];\n private declare target?: ITextBehavior;\n private __disposer: VoidFunction;\n\n constructor(canvas: Canvas) {\n const cb = () => {\n const { hiddenTextarea } =\n (canvas.getActiveObject() as ITextBehavior) || {};\n hiddenTextarea && hiddenTextarea.focus();\n };\n const el = canvas.upperCanvasEl;\n el.addEventListener('click', cb);\n this.__disposer = () => el.removeEventListener('click', cb);\n }\n\n exitTextEditing() {\n this.target = undefined;\n this.targets.forEach((target) => {\n if (target.isEditing) {\n target.exitEditing();\n }\n });\n }\n\n add(target: ITextBehavior) {\n this.targets.push(target);\n }\n\n remove(target: ITextBehavior) {\n this.unregister(target);\n removeFromArray(this.targets, target);\n }\n\n register(target: ITextBehavior) {\n this.target = target;\n }\n\n unregister(target: ITextBehavior) {\n if (target === this.target) {\n this.target = undefined;\n }\n }\n\n onMouseMove(e: TPointerEvent) {\n this.target?.isEditing && this.target.updateSelectionOnMouseMove(e);\n }\n\n clear() {\n this.targets = [];\n this.target = undefined;\n }\n\n dispose() {\n this.clear();\n this.__disposer();\n // @ts-expect-error disposing\n delete this.__disposer;\n }\n}\n","import { classRegistry } from '../ClassRegistry';\nimport { NONE } from '../constants';\nimport type {\n CanvasEvents,\n DragEventData,\n ObjectEvents,\n TPointerEvent,\n TPointerEventNames,\n Transform,\n} from '../EventTypeDefs';\nimport { Point } from '../Point';\nimport type { ActiveSelection } from '../shapes/ActiveSelection';\nimport type { Group } from '../shapes/Group';\nimport type { IText } from '../shapes/IText/IText';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { isTouchEvent, stopEvent } from '../util/dom_event';\nimport { getDocumentFromElement, getWindowFromElement } from '../util/dom_misc';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { isActiveSelection } from '../util/typeAssertions';\nimport type { CanvasOptions, TCanvasOptions } from './CanvasOptions';\nimport { SelectableCanvas } from './SelectableCanvas';\nimport { TextEditingManager } from './TextEditingManager';\n\nconst addEventOptions = { passive: false } as EventListenerOptions;\n\nconst getEventPoints = (canvas: Canvas, e: TPointerEvent) => {\n const viewportPoint = canvas.getViewportPoint(e);\n const scenePoint = canvas.getScenePoint(e);\n return {\n viewportPoint,\n scenePoint,\n pointer: viewportPoint,\n absolutePointer: scenePoint,\n };\n};\n\n// just to be clear, the utils are now deprecated and those are here exactly as minifier helpers\n// because el.addEventListener can't me be minified while a const yes and we use it 47 times in this file.\n// few bytes but why give it away.\nconst addListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.addEventListener(...args);\nconst removeListener = (\n el: HTMLElement | Document,\n ...args: Parameters\n) => el.removeEventListener(...args);\n\nconst syntheticEventConfig = {\n mouse: {\n in: 'over',\n out: 'out',\n targetIn: 'mouseover',\n targetOut: 'mouseout',\n canvasIn: 'mouse:over',\n canvasOut: 'mouse:out',\n },\n drag: {\n in: 'enter',\n out: 'leave',\n targetIn: 'dragenter',\n targetOut: 'dragleave',\n canvasIn: 'drag:enter',\n canvasOut: 'drag:leave',\n },\n} as const;\n\ntype TSyntheticEventContext = {\n mouse: { e: TPointerEvent };\n drag: DragEventData;\n};\n\nexport class Canvas extends SelectableCanvas implements CanvasOptions {\n /**\n * Contains the id of the touch event that owns the fabric transform\n * @type Number\n * @private\n */\n declare mainTouchId?: number;\n\n declare enablePointerEvents: boolean;\n\n /**\n * Holds a reference to a setTimeout timer for event synchronization\n * @type number\n * @private\n */\n private declare _willAddMouseDown: number;\n\n /**\n * Holds a reference to an object on the canvas that is receiving the drag over event.\n * @type FabricObject\n * @private\n */\n private declare _draggedoverTarget?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas from where the drag operation started\n * @type FabricObject\n * @private\n */\n private declare _dragSource?: FabricObject;\n\n /**\n * Holds a reference to an object on the canvas that is the current drop target\n * May differ from {@link _draggedoverTarget}\n * @todo inspect whether {@link _draggedoverTarget} and {@link _dropTarget} should be merged somehow\n * @type FabricObject\n * @private\n */\n private declare _dropTarget: FabricObject | undefined;\n\n private _isClick: boolean;\n\n textEditingManager = new TextEditingManager(this);\n\n constructor(el?: string | HTMLCanvasElement, options: TCanvasOptions = {}) {\n super(el, options);\n // bind event handlers\n (\n [\n '_onMouseDown',\n '_onTouchStart',\n '_onMouseMove',\n '_onMouseUp',\n '_onTouchEnd',\n '_onResize',\n // '_onGesture',\n // '_onDrag',\n // '_onShake',\n // '_onLongPress',\n // '_onOrientationChange',\n '_onMouseWheel',\n '_onMouseOut',\n '_onMouseEnter',\n '_onContextMenu',\n '_onDoubleClick',\n '_onDragStart',\n '_onDragEnd',\n '_onDragProgress',\n '_onDragOver',\n '_onDragEnter',\n '_onDragLeave',\n '_onDrop',\n ] as (keyof this)[]\n ).forEach((eventHandler) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n this[eventHandler] = (this[eventHandler] as Function).bind(this);\n });\n // register event handlers\n this.addOrRemove(addListener, 'add');\n }\n\n /**\n * return an event prefix pointer or mouse.\n * @private\n */\n private _getEventPrefix() {\n return this.enablePointerEvents ? 'pointer' : 'mouse';\n }\n\n addOrRemove(functor: any, _eventjsFunctor: 'add' | 'remove') {\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n functor(getWindowFromElement(canvasElement), 'resize', this._onResize);\n functor(canvasElement, eventTypePrefix + 'down', this._onMouseDown);\n functor(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove,\n addEventOptions,\n );\n functor(canvasElement, `${eventTypePrefix}out`, this._onMouseOut);\n functor(canvasElement, `${eventTypePrefix}enter`, this._onMouseEnter);\n functor(canvasElement, 'wheel', this._onMouseWheel);\n functor(canvasElement, 'contextmenu', this._onContextMenu);\n functor(canvasElement, 'dblclick', this._onDoubleClick);\n functor(canvasElement, 'dragstart', this._onDragStart);\n functor(canvasElement, 'dragend', this._onDragEnd);\n functor(canvasElement, 'dragover', this._onDragOver);\n functor(canvasElement, 'dragenter', this._onDragEnter);\n functor(canvasElement, 'dragleave', this._onDragLeave);\n functor(canvasElement, 'drop', this._onDrop);\n if (!this.enablePointerEvents) {\n functor(canvasElement, 'touchstart', this._onTouchStart, addEventOptions);\n }\n // if (typeof eventjs !== 'undefined' && eventjsFunctor in eventjs) {\n // eventjs[eventjsFunctor](canvasElement, 'gesture', this._onGesture);\n // eventjs[eventjsFunctor](canvasElement, 'drag', this._onDrag);\n // eventjs[eventjsFunctor](\n // canvasElement,\n // 'orientation',\n // this._onOrientationChange\n // );\n // eventjs[eventjsFunctor](canvasElement, 'shake', this._onShake);\n // eventjs[eventjsFunctor](canvasElement, 'longpress', this._onLongPress);\n // }\n }\n\n /**\n * Removes all event listeners, used when disposing the instance\n */\n removeListeners() {\n this.addOrRemove(removeListener, 'remove');\n // if you dispose on a mouseDown, before mouse up, you need to clean document to...\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n clearTimeout(this._willAddMouseDown);\n }\n\n /**\n * @private\n * @param {Event} [e] Event object fired on wheel event\n */\n private _onMouseWheel(e: MouseEvent) {\n this.__onMouseWheel(e);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onMouseOut(e: TPointerEvent) {\n const target = this._hoveredTarget;\n const shared = {\n e,\n ...getEventPoints(this, e),\n };\n this.fire('mouse:out', { ...shared, target });\n this._hoveredTarget = undefined;\n target && target.fire('mouseout', { ...shared });\n this._hoveredTargets.forEach((nestedTarget) => {\n this.fire('mouse:out', { ...shared, target: nestedTarget });\n nestedTarget && nestedTarget.fire('mouseout', { ...shared });\n });\n this._hoveredTargets = [];\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseenter\n */\n private _onMouseEnter(e: TPointerEvent) {\n // This find target and consequent 'mouse:over' is used to\n // clear old instances on hovered target.\n // calling findTarget has the side effect of killing target.__corner.\n // as a short term fix we are not firing this if we are currently transforming.\n // as a long term fix we need to separate the action of finding a target with the\n // side effects we added to it.\n if (!this._currentTransform && !this.findTarget(e)) {\n this.fire('mouse:over', {\n e,\n ...getEventPoints(this, e),\n });\n this._hoveredTarget = undefined;\n this._hoveredTargets = [];\n }\n }\n\n /**\n * supports native like text dragging\n * @private\n * @param {DragEvent} e\n */\n private _onDragStart(e: DragEvent) {\n this._isClick = false;\n const activeObject = this.getActiveObject();\n if (activeObject && activeObject.onDragStart(e)) {\n this._dragSource = activeObject;\n const options = { e, target: activeObject };\n this.fire('dragstart', options);\n activeObject.fire('dragstart', options);\n addListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n return;\n }\n stopEvent(e);\n }\n\n /**\n * First we clear top context where the effects are being rendered.\n * Then we render the effects.\n * Doing so will render the correct effect for all cases including an overlap between `source` and `target`.\n * @private\n */\n private _renderDragEffects(\n e: DragEvent,\n source?: FabricObject,\n target?: FabricObject,\n ) {\n let dirty = false;\n // clear top context\n const dropTarget = this._dropTarget;\n if (dropTarget && dropTarget !== source && dropTarget !== target) {\n dropTarget.clearContextTop();\n dirty = true;\n }\n source?.clearContextTop();\n target !== source && target?.clearContextTop();\n // render effects\n const ctx = this.contextTop;\n ctx.save();\n ctx.transform(...this.viewportTransform);\n if (source) {\n ctx.save();\n source.transform(ctx);\n source.renderDragSourceEffect(e);\n ctx.restore();\n dirty = true;\n }\n if (target) {\n ctx.save();\n target.transform(ctx);\n target.renderDropTargetEffect(e);\n ctx.restore();\n dirty = true;\n }\n ctx.restore();\n dirty && (this.contextTopDirty = true);\n }\n\n /**\n * supports native like text dragging\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n * @private\n * @param {DragEvent} e\n */\n private _onDragEnd(e: DragEvent) {\n const didDrop = !!e.dataTransfer && e.dataTransfer.dropEffect !== NONE,\n dropTarget = didDrop ? this._activeObject : undefined,\n options = {\n e,\n target: this._dragSource as FabricObject,\n subTargets: this.targets,\n dragSource: this._dragSource as FabricObject,\n didDrop,\n dropTarget: dropTarget as FabricObject,\n };\n removeListener(\n this.upperCanvasEl,\n 'drag',\n this._onDragProgress as EventListener,\n );\n this.fire('dragend', options);\n this._dragSource && this._dragSource.fire('dragend', options);\n delete this._dragSource;\n // we need to call mouse up synthetically because the browser won't\n this._onMouseUp(e);\n }\n\n /**\n * fire `drag` event on canvas and drag source\n * @private\n * @param {DragEvent} e\n */\n private _onDragProgress(e: DragEvent) {\n const options = {\n e,\n target: this._dragSource as FabricObject | undefined,\n dragSource: this._dragSource as FabricObject | undefined,\n dropTarget: this._draggedoverTarget as FabricObject,\n };\n this.fire('drag', options);\n this._dragSource && this._dragSource.fire('drag', options);\n }\n\n /**\n * As opposed to {@link findTarget} we want the top most object to be returned w/o the active object cutting in line.\n * Override at will\n */\n protected findDragTargets(e: DragEvent) {\n this.targets = [];\n const target = this._searchPossibleTargets(\n this._objects,\n this.getViewportPoint(e),\n );\n return {\n target,\n targets: [...this.targets],\n };\n }\n\n /**\n * prevent default to allow drop event to be fired\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#specifying_drop_targets\n * @private\n * @param {DragEvent} [e] Event object fired on Event.js shake\n */\n private _onDragOver(e: DragEvent) {\n const eventType = 'dragover';\n const { target, targets } = this.findDragTargets(e);\n const dragSource = this._dragSource as FabricObject;\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource,\n canDrop: false,\n dropTarget: undefined,\n };\n let dropTarget;\n // fire on canvas\n this.fire(eventType, options);\n // make sure we fire dragenter events before dragover\n // if dragleave is needed, object will not fire dragover so we don't need to trouble ourselves with it\n this._fireEnterLeaveEvents(target, options);\n if (target) {\n if (target.canDrop(e)) {\n dropTarget = target;\n }\n target.fire(eventType, options);\n }\n // propagate the event to subtargets\n for (let i = 0; i < targets.length; i++) {\n const subTarget = targets[i];\n // accept event only if previous targets didn't (the accepting target calls `preventDefault` to inform that the event is taken)\n // TODO: verify if those should loop in inverse order then?\n // what is the order of subtargets?\n if (subTarget.canDrop(e)) {\n dropTarget = subTarget;\n }\n subTarget.fire(eventType, options);\n }\n // render drag effects now that relations between source and target is clear\n this._renderDragEffects(e, dragSource, dropTarget);\n this._dropTarget = dropTarget;\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragEnter(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n };\n this.fire('dragenter', options);\n // fire dragenter on targets\n this._fireEnterLeaveEvents(target, options);\n }\n\n /**\n * fire `dragleave` on `dragover` targets\n * @private\n * @param {Event} [e] Event object fired on Event.js shake\n */\n private _onDragLeave(e: DragEvent) {\n const options = {\n e,\n target: this._draggedoverTarget,\n subTargets: this.targets,\n dragSource: this._dragSource,\n };\n this.fire('dragleave', options);\n\n // fire dragleave on targets\n this._fireEnterLeaveEvents(undefined, options);\n this._renderDragEffects(e, this._dragSource);\n this._dropTarget = undefined;\n // clear targets\n this.targets = [];\n this._hoveredTargets = [];\n }\n\n /**\n * `drop:before` is a an event that allows you to schedule logic\n * before the `drop` event. Prefer `drop` event always, but if you need\n * to run some drop-disabling logic on an event, since there is no way\n * to handle event handlers ordering, use `drop:before`\n * @private\n * @param {Event} e\n */\n private _onDrop(e: DragEvent) {\n const { target, targets } = this.findDragTargets(e);\n const options = this._basicEventHandler('drop:before', {\n e,\n target,\n subTargets: targets,\n dragSource: this._dragSource,\n ...getEventPoints(this, e),\n });\n // will be set by the drop target\n options.didDrop = false;\n // will be set by the drop target, used in case options.target refuses the drop\n options.dropTarget = undefined;\n // fire `drop`\n this._basicEventHandler('drop', options);\n // inform canvas of the drop\n // we do this because canvas was unaware of what happened at the time the `drop` event was fired on it\n // use for side effects\n this.fire('drop:after', options);\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onContextMenu(e: TPointerEvent): false {\n const target = this.findTarget(e),\n subTargets = this.targets || [];\n const options = this._basicEventHandler('contextmenu:before', {\n e,\n target,\n subTargets,\n });\n // TODO: this line is silly because the dev can subscribe to the event and prevent it themselves\n this.stopContextMenu && stopEvent(e);\n this._basicEventHandler('contextmenu', options);\n return false;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n private _onDoubleClick(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'dblclick');\n this._resetTransformEventData();\n }\n\n /**\n * Return a the id of an event.\n * returns either the pointerId or the identifier or 0 for the mouse event\n * @private\n * @param {Event} evt Event object\n */\n getPointerId(evt: TouchEvent | PointerEvent): number {\n const changedTouches = (evt as TouchEvent).changedTouches;\n\n if (changedTouches) {\n return changedTouches[0] && changedTouches[0].identifier;\n }\n\n if (this.enablePointerEvents) {\n return (evt as PointerEvent).pointerId;\n }\n\n return -1;\n }\n\n /**\n * Determines if an event has the id of the event that is considered main\n * @private\n * @param {evt} event Event object\n */\n _isMainEvent(evt: TPointerEvent): boolean {\n if ((evt as PointerEvent).isPrimary === true) {\n return true;\n }\n if ((evt as PointerEvent).isPrimary === false) {\n return false;\n }\n if (evt.type === 'touchend' && (evt as TouchEvent).touches.length === 0) {\n return true;\n }\n if ((evt as TouchEvent).changedTouches) {\n return (\n (evt as TouchEvent).changedTouches[0].identifier === this.mainTouchId\n );\n }\n return true;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchStart(e: TouchEvent) {\n // we will prevent scrolling if allowTouchScrolling is not enabled and\n let shouldPreventScrolling = !this.allowTouchScrolling;\n const currentActiveObject = this._activeObject;\n if (this.mainTouchId === undefined) {\n this.mainTouchId = this.getPointerId(e);\n }\n this.__onMouseDown(e);\n // after executing fabric logic for mouse down let's see\n // if we didn't change target or if we are drawing\n // we want to prevent scrolling anyway\n if (\n this.isDrawingMode ||\n (currentActiveObject && this._target === currentActiveObject)\n ) {\n shouldPreventScrolling = true;\n }\n // prevent default, will block scrolling from start\n shouldPreventScrolling && e.preventDefault();\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(canvasElement);\n addListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n // if we scroll don't register the touch move event\n shouldPreventScrolling &&\n addListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n // Unbind mousedown to prevent double triggers from touch devices\n removeListener(\n canvasElement,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDown(e: TPointerEvent) {\n this.__onMouseDown(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n removeListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n const doc = getDocumentFromElement(canvasElement);\n addListener(doc, `${eventTypePrefix}up`, this._onMouseUp as EventListener);\n addListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onTouchEnd(e: TouchEvent) {\n if (e.touches.length > 0) {\n // if there are still touches stop here\n return;\n }\n this.__onMouseUp(e);\n this._resetTransformEventData();\n delete this.mainTouchId;\n const eventTypePrefix = this._getEventPrefix();\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n 'touchend',\n this._onTouchEnd as EventListener,\n addEventOptions,\n );\n removeListener(\n doc,\n 'touchmove',\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n if (this._willAddMouseDown) {\n clearTimeout(this._willAddMouseDown);\n }\n this._willAddMouseDown = setTimeout(() => {\n // Wait 400ms before rebinding mousedown to prevent double triggers\n // from touch devices\n addListener(\n this.upperCanvasEl,\n `${eventTypePrefix}down`,\n this._onMouseDown as EventListener,\n );\n this._willAddMouseDown = 0;\n }, 400) as unknown as number;\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUp(e: TPointerEvent) {\n this.__onMouseUp(e);\n this._resetTransformEventData();\n const canvasElement = this.upperCanvasEl,\n eventTypePrefix = this._getEventPrefix();\n if (this._isMainEvent(e)) {\n const doc = getDocumentFromElement(this.upperCanvasEl);\n removeListener(\n doc,\n `${eventTypePrefix}up`,\n this._onMouseUp as EventListener,\n );\n removeListener(\n doc,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n addListener(\n canvasElement,\n `${eventTypePrefix}move`,\n this._onMouseMove as EventListener,\n addEventOptions,\n );\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMove(e: TPointerEvent) {\n const activeObject = this.getActiveObject();\n !this.allowTouchScrolling &&\n (!activeObject ||\n // a drag event sequence is started by the active object flagging itself on mousedown / mousedown:before\n // we must not prevent the event's default behavior in order for the window to start dragging\n !activeObject.shouldStartDragging(e)) &&\n e.preventDefault &&\n e.preventDefault();\n this.__onMouseMove(e);\n }\n\n /**\n * @private\n */\n _onResize() {\n this.calcOffset();\n this._resetTransformEventData();\n }\n\n /**\n * Decides whether the canvas should be redrawn in mouseup and mousedown events.\n * @private\n * @param {Object} target\n */\n _shouldRender(target: FabricObject | undefined) {\n const activeObject = this.getActiveObject();\n // if just one of them is available or if they are both but are different objects\n // this covers: switch of target, from target to no target, selection of target\n // multiSelection with key and mouse\n return (\n !!activeObject !== !!target ||\n (activeObject && target && activeObject !== target)\n );\n }\n\n /**\n * Method that defines the actions when mouse is released on canvas.\n * The method resets the currentTransform parameters, store the image corner\n * position in the image object and render the canvas on top.\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseUp(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'up:before');\n\n const transform = this._currentTransform;\n const isClick = this._isClick;\n const target = this._target;\n\n // if right/middle click just fire events and return\n // target undefined will make the _handleEvent search the target\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'up');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode && this._isCurrentlyDrawing) {\n this._onMouseUpInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n let shouldRender = false;\n if (transform) {\n this._finalizeCurrentTransform(e);\n shouldRender = transform.actionPerformed;\n }\n if (!isClick) {\n const targetWasActive = target === this._activeObject;\n this.handleSelection(e);\n if (!shouldRender) {\n shouldRender =\n this._shouldRender(target) ||\n (!targetWasActive && target === this._activeObject);\n }\n }\n let pointer, corner;\n if (target) {\n const found = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n const { key, control } = found || {};\n corner = key;\n if (\n target.selectable &&\n target !== this._activeObject &&\n target.activeOn === 'up'\n ) {\n this.setActiveObject(target, e);\n shouldRender = true;\n } else if (control) {\n const mouseUpHandler = control.getMouseUpHandler(e, target, control);\n if (mouseUpHandler) {\n pointer = this.getScenePoint(e);\n mouseUpHandler.call(control, e, transform!, pointer.x, pointer.y);\n }\n }\n target.isMoving = false;\n }\n // if we are ending up a transform on a different control or a new object\n // fire the original mouse up from the corner that started the transform\n if (\n transform &&\n (transform.target !== target || transform.corner !== corner)\n ) {\n const originalControl =\n transform.target && transform.target.controls[transform.corner],\n originalMouseUpHandler =\n originalControl &&\n originalControl.getMouseUpHandler(\n e,\n transform.target,\n originalControl,\n );\n pointer = pointer || this.getScenePoint(e);\n originalMouseUpHandler &&\n originalMouseUpHandler.call(\n originalControl,\n e,\n transform,\n pointer.x,\n pointer.y,\n );\n }\n this._setCursorFromEvent(e, target);\n this._handleEvent(e, 'up');\n this._groupSelector = null;\n this._currentTransform = null;\n // reset the target information about which corner is selected\n target && (target.__corner = undefined);\n if (shouldRender) {\n this.requestRenderAll();\n } else if (!isClick && !(this._activeObject as IText)?.isEditing) {\n this.renderTop();\n }\n }\n\n _basicEventHandler(\n eventType: T,\n options: (CanvasEvents & ObjectEvents)[T],\n ) {\n const { target, subTargets = [] } = options as {\n target?: FabricObject;\n subTargets: FabricObject[];\n };\n this.fire(eventType, options);\n target && target.fire(eventType, options);\n for (let i = 0; i < subTargets.length; i++) {\n subTargets[i] !== target && subTargets[i].fire(eventType, options);\n }\n return options;\n }\n\n /**\n * @private\n * Handle event firing for target and subtargets\n * @param {TPointerEvent} e event from mouse\n * @param {TPointerEventNames} eventType\n */\n _handleEvent(e: TPointerEvent, eventType: T) {\n const target = this._target,\n targets = this.targets || [],\n options: CanvasEvents[`mouse:${T}`] = {\n e,\n target,\n subTargets: targets,\n ...getEventPoints(this, e),\n transform: this._currentTransform,\n ...(eventType === 'up:before' || eventType === 'up'\n ? {\n isClick: this._isClick,\n currentTarget: this.findTarget(e),\n // set by the preceding `findTarget` call\n currentSubTargets: this.targets,\n }\n : {}),\n } as CanvasEvents[`mouse:${T}`];\n this.fire(`mouse:${eventType}`, options);\n // this may be a little be more complicated of what we want to handle\n target && target.fire(`mouse${eventType}`, options);\n for (let i = 0; i < targets.length; i++) {\n targets[i] !== target && targets[i].fire(`mouse${eventType}`, options);\n }\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n _onMouseDownInDrawingMode(e: TPointerEvent) {\n this._isCurrentlyDrawing = true;\n if (this.getActiveObject()) {\n this.discardActiveObject(e);\n this.requestRenderAll();\n }\n // TODO: this is a scene point so it should be renamed\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseDown(pointer, { e, pointer });\n this._handleEvent(e, 'down');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n _onMouseMoveInDrawingMode(e: TPointerEvent) {\n if (this._isCurrentlyDrawing) {\n const pointer = this.getScenePoint(e);\n this.freeDrawingBrush &&\n this.freeDrawingBrush.onMouseMove(pointer, {\n e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n }\n this.setCursor(this.freeDrawingCursor);\n this._handleEvent(e, 'move');\n }\n\n /**\n * @private\n * @param {Event} e Event object fired on mouseup\n */\n _onMouseUpInDrawingMode(e: TPointerEvent) {\n const pointer = this.getScenePoint(e);\n if (this.freeDrawingBrush) {\n this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({\n e: e,\n // this is an absolute pointer, the naming is wrong\n pointer,\n });\n } else {\n this._isCurrentlyDrawing = false;\n }\n this._handleEvent(e, 'up');\n }\n\n /**\n * Method that defines the actions when mouse is clicked on canvas.\n * The method inits the currentTransform parameters and renders all the\n * canvas so the current image can be placed on the top canvas and the rest\n * in on the container one.\n * @private\n * @param {Event} e Event object fired on mousedown\n */\n __onMouseDown(e: TPointerEvent) {\n this._isClick = true;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'down:before');\n\n let target: FabricObject | undefined = this._target;\n\n // if right/middle click just fire events\n const { button } = e as MouseEvent;\n if (button) {\n ((this.fireMiddleClick && button === 1) ||\n (this.fireRightClick && button === 2)) &&\n this._handleEvent(e, 'down');\n this._resetTransformEventData();\n return;\n }\n\n if (this.isDrawingMode) {\n this._onMouseDownInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n // ignore if some object is being transformed at this moment\n if (this._currentTransform) {\n return;\n }\n\n let shouldRender = this._shouldRender(target);\n let grouped = false;\n if (this.handleMultiSelection(e, target)) {\n // active object might have changed while grouping\n target = this._activeObject;\n grouped = true;\n shouldRender = true;\n } else if (this._shouldClearSelection(e, target)) {\n this.discardActiveObject(e);\n }\n // we start a group selector rectangle if\n // selection is enabled\n // and there is no target, or the following 3 conditions are satisfied:\n // target is not selectable ( otherwise we selected it )\n // target is not editing\n // target is not already selected ( otherwise we drag )\n if (\n this.selection &&\n (!target ||\n (!target.selectable &&\n !(target as IText).isEditing &&\n target !== this._activeObject))\n ) {\n const p = this.getScenePoint(e);\n this._groupSelector = {\n x: p.x,\n y: p.y,\n deltaY: 0,\n deltaX: 0,\n };\n }\n\n if (target) {\n const alreadySelected = target === this._activeObject;\n if (target.selectable && target.activeOn === 'down') {\n this.setActiveObject(target, e);\n }\n const handle = target.findControl(\n this.getViewportPoint(e),\n isTouchEvent(e),\n );\n if (target === this._activeObject && (handle || !grouped)) {\n this._setupCurrentTransform(e, target, alreadySelected);\n const control = handle ? handle.control : undefined,\n pointer = this.getScenePoint(e),\n mouseDownHandler =\n control && control.getMouseDownHandler(e, target, control);\n mouseDownHandler &&\n mouseDownHandler.call(\n control,\n e,\n this._currentTransform!,\n pointer.x,\n pointer.y,\n );\n }\n }\n // we clear `_objectsToRender` in case of a change in order to repopulate it at rendering\n // run before firing the `down` event to give the dev a chance to populate it themselves\n shouldRender && (this._objectsToRender = undefined);\n this._handleEvent(e, 'down');\n // we must renderAll so that we update the visuals\n shouldRender && this.requestRenderAll();\n }\n\n /**\n * reset cache form common information needed during event processing\n * @private\n */\n _resetTransformEventData() {\n this._target = this._pointer = this._absolutePointer = undefined;\n }\n\n /**\n * Cache common information needed during event processing\n * @private\n * @param {Event} e Event object fired on event\n */\n _cacheTransformEventData(e: TPointerEvent) {\n // reset in order to avoid stale caching\n this._resetTransformEventData();\n this._pointer = this.getViewportPoint(e);\n this._absolutePointer = sendPointToPlane(\n this._pointer,\n undefined,\n this.viewportTransform,\n );\n this._target = this._currentTransform\n ? this._currentTransform.target\n : this.findTarget(e);\n }\n\n /**\n * Method that defines the actions when mouse is hovering the canvas.\n * The currentTransform parameter will define whether the user is rotating/scaling/translating\n * an image or neither of them (only hovering). A group selection is also possible and would cancel\n * all any other type of action.\n * In case of an image transformation only the top canvas will be rendered.\n * @private\n * @param {Event} e Event object fired on mousemove\n */\n __onMouseMove(e: TPointerEvent) {\n this._isClick = false;\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'move:before');\n\n if (this.isDrawingMode) {\n this._onMouseMoveInDrawingMode(e);\n return;\n }\n\n if (!this._isMainEvent(e)) {\n return;\n }\n\n const groupSelector = this._groupSelector;\n\n // We initially clicked in an empty area, so we draw a box for multiple selection\n if (groupSelector) {\n const pointer = this.getScenePoint(e);\n\n groupSelector.deltaX = pointer.x - groupSelector.x;\n groupSelector.deltaY = pointer.y - groupSelector.y;\n\n this.renderTop();\n } else if (!this._currentTransform) {\n const target = this.findTarget(e);\n this._setCursorFromEvent(e, target);\n this._fireOverOutEvents(e, target);\n } else {\n this._transformObject(e);\n }\n this.textEditingManager.onMouseMove(e);\n this._handleEvent(e, 'move');\n this._resetTransformEventData();\n }\n\n /**\n * Manage the mouseout, mouseover events for the fabric object on the canvas\n * @param {Fabric.Object} target the target where the target from the mousemove event\n * @param {Event} e Event object fired on mousemove\n * @private\n */\n _fireOverOutEvents(e: TPointerEvent, target?: FabricObject) {\n const _hoveredTarget = this._hoveredTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target,\n oldTarget: _hoveredTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('mouse', {\n e,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._hoveredTarget = target;\n this._hoveredTargets = this.targets.concat();\n }\n\n /**\n * Manage the dragEnter, dragLeave events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the onDrag event\n * @param {Object} data Event object fired on dragover\n * @private\n */\n _fireEnterLeaveEvents(target: FabricObject | undefined, data: DragEventData) {\n const draggedoverTarget = this._draggedoverTarget,\n _hoveredTargets = this._hoveredTargets,\n targets = this.targets,\n length = Math.max(_hoveredTargets.length, targets.length);\n\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target,\n oldTarget: draggedoverTarget,\n fireCanvas: true,\n });\n for (let i = 0; i < length; i++) {\n this.fireSyntheticInOutEvents('drag', {\n ...data,\n target: targets[i],\n oldTarget: _hoveredTargets[i],\n });\n }\n this._draggedoverTarget = target;\n }\n\n /**\n * Manage the synthetic in/out events for the fabric objects on the canvas\n * @param {Fabric.Object} target the target where the target from the supported events\n * @param {Object} data Event object fired\n * @param {Object} config configuration for the function to work\n * @param {String} config.targetName property on the canvas where the old target is stored\n * @param {String} [config.canvasEvtOut] name of the event to fire at canvas level for out\n * @param {String} config.evtOut name of the event to fire for out\n * @param {String} [config.canvasEvtIn] name of the event to fire at canvas level for in\n * @param {String} config.evtIn name of the event to fire for in\n * @private\n */\n fireSyntheticInOutEvents(\n type: T,\n {\n target,\n oldTarget,\n fireCanvas,\n e,\n ...data\n }: TSyntheticEventContext[T] & {\n target?: FabricObject;\n oldTarget?: FabricObject;\n fireCanvas?: boolean;\n },\n ) {\n const { targetIn, targetOut, canvasIn, canvasOut } =\n syntheticEventConfig[type];\n const targetChanged = oldTarget !== target;\n\n if (oldTarget && targetChanged) {\n const outOpt: CanvasEvents[typeof canvasOut] = {\n ...data,\n e,\n target: oldTarget,\n nextTarget: target,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasOut, outOpt);\n oldTarget.fire(targetOut, outOpt);\n }\n if (target && targetChanged) {\n const inOpt: CanvasEvents[typeof canvasIn] = {\n ...data,\n e,\n target,\n previousTarget: oldTarget,\n ...getEventPoints(this, e),\n };\n fireCanvas && this.fire(canvasIn, inOpt);\n target.fire(targetIn, inOpt);\n }\n }\n\n /**\n * Method that defines actions when an Event Mouse Wheel\n * @param {Event} e Event object fired on mouseup\n */\n __onMouseWheel(e: TPointerEvent) {\n this._cacheTransformEventData(e);\n this._handleEvent(e, 'wheel');\n this._resetTransformEventData();\n }\n\n /**\n * @private\n * @param {Event} e Event fired on mousemove\n */\n _transformObject(e: TPointerEvent) {\n const scenePoint = this.getScenePoint(e),\n transform = this._currentTransform!,\n target = transform.target,\n // transform pointer to target's containing coordinate plane\n // both pointer and object should agree on every point\n localPointer = target.group\n ? sendPointToPlane(\n scenePoint,\n undefined,\n target.group.calcTransformMatrix(),\n )\n : scenePoint;\n transform.shiftKey = e.shiftKey;\n transform.altKey = !!this.centeredKey && e[this.centeredKey];\n\n this._performTransformAction(e, transform, localPointer);\n transform.actionPerformed && this.requestRenderAll();\n }\n\n /**\n * @private\n */\n _performTransformAction(\n e: TPointerEvent,\n transform: Transform,\n pointer: Point,\n ) {\n const { action, actionHandler, target } = transform;\n\n const actionPerformed =\n !!actionHandler && actionHandler(e, transform, pointer.x, pointer.y);\n actionPerformed && target.setCoords();\n\n // this object could be created from the function in the control handlers\n if (action === 'drag' && actionPerformed) {\n transform.target.isMoving = true;\n this.setCursor(transform.target.moveCursor || this.moveCursor);\n }\n transform.actionPerformed = transform.actionPerformed || actionPerformed;\n }\n\n /**\n * Sets the cursor depending on where the canvas is being hovered.\n * Note: very buggy in Opera\n * @param {Event} e Event object\n * @param {Object} target Object that the mouse is hovering, if so.\n */\n _setCursorFromEvent(e: TPointerEvent, target?: FabricObject) {\n if (!target) {\n this.setCursor(this.defaultCursor);\n return;\n }\n let hoverCursor = target.hoverCursor || this.hoverCursor;\n const activeSelection = isActiveSelection(this._activeObject)\n ? this._activeObject\n : null,\n // only show proper corner when group selection is not active\n corner =\n (!activeSelection || target.group !== activeSelection) &&\n // here we call findTargetCorner always with undefined for the touch parameter.\n // we assume that if you are using a cursor you do not need to interact with\n // the bigger touch area.\n target.findControl(this.getViewportPoint(e));\n\n if (!corner) {\n if ((target as Group).subTargetCheck) {\n // hoverCursor should come from top-most subTarget,\n // so we walk the array backwards\n this.targets\n .concat()\n .reverse()\n .map((_target) => {\n hoverCursor = _target.hoverCursor || hoverCursor;\n });\n }\n this.setCursor(hoverCursor);\n } else {\n const control = corner.control;\n this.setCursor(control.cursorStyleHandler(e, control, target));\n }\n }\n\n /**\n * ## Handles multiple selection\n * - toggles `target` selection (selects/deselects `target` if it isn't/is selected respectively)\n * - sets the active object in case it is not set or in case there is a single active object left under active selection.\n * ---\n * - If the active object is the active selection we add/remove `target` from it\n * - If not, add the active object and `target` to the active selection and make it the active object.\n * @private\n * @param {TPointerEvent} e Event object\n * @param {FabricObject} target target of event to select/deselect\n * @returns true if grouping occurred\n */\n protected handleMultiSelection(e: TPointerEvent, target?: FabricObject) {\n const activeObject = this._activeObject;\n const isAS = isActiveSelection(activeObject);\n if (\n // check if an active object exists on canvas and if the user is pressing the `selectionKey` while canvas supports multi selection.\n !!activeObject &&\n this._isSelectionKeyPressed(e) &&\n this.selection &&\n // on top of that the user also has to hit a target that is selectable.\n !!target &&\n target.selectable &&\n // group target and active object only if they are different objects\n // else we try to find a subtarget of `ActiveSelection`\n (activeObject !== target || isAS) &&\n // make sure `activeObject` and `target` aren't ancestors of each other in case `activeObject` is not `ActiveSelection`\n // if it is then we want to remove `target` from it\n (isAS ||\n (!target.isDescendantOf(activeObject) &&\n !activeObject.isDescendantOf(target))) &&\n // target accepts selection\n !target.onSelect({ e }) &&\n // make sure we are not on top of a control\n !activeObject.getActiveControl()\n ) {\n if (isAS) {\n const prevActiveObjects = activeObject.getObjects();\n if (target === activeObject) {\n const pointer = this.getViewportPoint(e);\n target =\n // first search active objects for a target to remove\n this.searchPossibleTargets(prevActiveObjects, pointer) ||\n // if not found, search under active selection for a target to add\n // `prevActiveObjects` will be searched but we already know they will not be found\n this.searchPossibleTargets(this._objects, pointer);\n // if nothing is found bail out\n if (!target || !target.selectable) {\n return false;\n }\n }\n if (target.group === activeObject) {\n // `target` is part of active selection => remove it\n activeObject.remove(target);\n this._hoveredTarget = target;\n this._hoveredTargets = [...this.targets];\n // if after removing an object we are left with one only...\n if (activeObject.size() === 1) {\n // activate last remaining object\n // deselecting the active selection will remove the remaining object from it\n this._setActiveObject(activeObject.item(0), e);\n }\n } else {\n // `target` isn't part of active selection => add it\n activeObject.multiSelectAdd(target);\n this._hoveredTarget = activeObject;\n this._hoveredTargets = [...this.targets];\n }\n this._fireSelectionEvents(prevActiveObjects, e);\n } else {\n (activeObject as IText).isEditing &&\n (activeObject as IText).exitEditing();\n // add the active object and the target to the active selection and set it as the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n const newActiveSelection = new klass([], {\n /**\n * it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}\n * since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref\n */\n canvas: this,\n });\n newActiveSelection.multiSelectAdd(activeObject, target);\n this._hoveredTarget = newActiveSelection;\n // ISSUE 4115: should we consider subTargets here?\n // this._hoveredTargets = [];\n // this._hoveredTargets = this.targets.concat();\n this._setActiveObject(newActiveSelection, e);\n this._fireSelectionEvents([activeObject], e);\n }\n return true;\n }\n return false;\n }\n\n /**\n * ## Handles selection\n * - selects objects that are contained in (and possibly intersecting) the selection bounding box\n * - sets the active object\n * ---\n * runs on mouse up after a mouse move\n */\n protected handleSelection(e: TPointerEvent) {\n if (!this.selection || !this._groupSelector) {\n return false;\n }\n const { x, y, deltaX, deltaY } = this._groupSelector,\n point1 = new Point(x, y),\n point2 = point1.add(new Point(deltaX, deltaY)),\n tl = point1.min(point2),\n br = point1.max(point2),\n size = br.subtract(tl);\n\n const collectedObjects = this.collectObjects(\n {\n left: tl.x,\n top: tl.y,\n width: size.x,\n height: size.y,\n },\n { includeIntersecting: !this.selectionFullyContained },\n ) as FabricObject[];\n\n const objects =\n // though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down\n // should it be handled as is?\n point1.eq(point2)\n ? collectedObjects[0]\n ? [collectedObjects[0]]\n : []\n : collectedObjects.length > 1\n ? collectedObjects\n .filter((object) => !object.onSelect({ e }))\n .reverse()\n : // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case\n collectedObjects;\n\n // set active object\n if (objects.length === 1) {\n // set as active object\n this.setActiveObject(objects[0], e);\n } else if (objects.length > 1) {\n // add to active selection and make it the active object\n const klass =\n classRegistry.getClass('ActiveSelection');\n this.setActiveObject(new klass(objects, { canvas: this }), e);\n }\n\n // cleanup\n this._groupSelector = null;\n return true;\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n clear() {\n this.textEditingManager.clear();\n super.clear();\n }\n\n /**\n * @override clear {@link textEditingManager}\n */\n destroy() {\n this.removeListeners();\n this.textEditingManager.dispose();\n super.destroy();\n }\n}\n","export const linearDefaultCoords = {\n x1: 0,\n y1: 0,\n x2: 0,\n y2: 0,\n};\n\nexport const radialDefaultCoords = {\n ...linearDefaultCoords,\n r1: 0,\n r2: 0,\n};\n","/**\n *\n * @param value value to check if NaN\n * @param [valueIfNaN]\n * @returns `fallback` is `value is NaN\n */\nexport const ifNaN = (value: number, valueIfNaN?: number) => {\n return isNaN(value) && typeof valueIfNaN === 'number' ? valueIfNaN : value;\n};\n","import { ifNaN } from '../util/internals/ifNaN';\nimport { capValue } from '../util/misc/capValue';\n\nconst RE_PERCENT = /^(\\d+\\.\\d+)%|(\\d+)%$/;\n\nexport function isPercent(value: string | null) {\n return value && RE_PERCENT.test(value);\n}\n\n/**\n *\n * @param value\n * @param valueIfNaN\n * @returns ∈ [0, 1]\n */\nexport function parsePercent(\n value: string | number | null | undefined,\n valueIfNaN?: number,\n) {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string'\n ? parseFloat(value) / (isPercent(value) ? 100 : 1)\n : NaN;\n return capValue(0, ifNaN(parsed, valueIfNaN), 1);\n}\n","import { Color } from '../../color/Color';\nimport { parsePercent } from '../../parser/percent';\nimport { ifNaN } from '../../util/internals/ifNaN';\nimport type { ColorStop } from '../typedefs';\n\nconst RE_KEY_VALUE_PAIRS = /\\s*;\\s*/;\nconst RE_KEY_VALUE = /\\s*:\\s*/;\n\nfunction parseColorStop(el: SVGStopElement, multiplier: number) {\n let colorValue, opacity;\n const style = el.getAttribute('style');\n if (style) {\n const keyValuePairs = style.split(RE_KEY_VALUE_PAIRS);\n\n if (keyValuePairs[keyValuePairs.length - 1] === '') {\n keyValuePairs.pop();\n }\n\n for (let i = keyValuePairs.length; i--; ) {\n const [key, value] = keyValuePairs[i]\n .split(RE_KEY_VALUE)\n .map((s) => s.trim());\n if (key === 'stop-color') {\n colorValue = value;\n } else if (key === 'stop-opacity') {\n opacity = value;\n }\n }\n }\n\n const color = new Color(\n colorValue || el.getAttribute('stop-color') || 'rgb(0,0,0)',\n );\n\n return {\n offset: parsePercent(el.getAttribute('offset'), 0),\n color: color.toRgb(),\n opacity:\n ifNaN(parseFloat(opacity || el.getAttribute('stop-opacity') || ''), 1) *\n color.getAlpha() *\n multiplier,\n };\n}\n\nexport function parseColorStops(\n el: SVGGradientElement,\n opacityAttr: string | null,\n) {\n const colorStops: ColorStop[] = [],\n colorStopEls = el.getElementsByTagName('stop'),\n multiplier = parsePercent(opacityAttr, 1);\n for (let i = colorStopEls.length; i--; ) {\n colorStops.push(parseColorStop(colorStopEls[i], multiplier));\n }\n return colorStops;\n}\n","import type { GradientType, GradientUnits } from '../typedefs';\n\nexport function parseType(el: SVGGradientElement): GradientType {\n return el.nodeName === 'linearGradient' || el.nodeName === 'LINEARGRADIENT'\n ? 'linear'\n : 'radial';\n}\n\nexport function parseGradientUnits(el: SVGGradientElement): GradientUnits {\n return el.getAttribute('gradientUnits') === 'userSpaceOnUse'\n ? 'pixels'\n : 'percentage';\n}\n","import { isPercent } from '../../parser/percent';\nimport type { TSize } from '../../typedefs';\nimport type { GradientCoords, GradientType, GradientUnits } from '../typedefs';\nimport { parseGradientUnits, parseType } from './misc';\n\nfunction convertPercentUnitsToValues<\n T extends GradientType,\n K extends keyof GradientCoords,\n>(\n valuesToConvert: Record,\n { width, height, gradientUnits }: TSize & { gradientUnits: GradientUnits },\n) {\n let finalValue;\n return (Object.keys(valuesToConvert) as K[]).reduce(\n (acc, prop) => {\n const propValue = valuesToConvert[prop];\n if (propValue === 'Infinity') {\n finalValue = 1;\n } else if (propValue === '-Infinity') {\n finalValue = 0;\n } else {\n finalValue =\n typeof propValue === 'string' ? parseFloat(propValue) : propValue;\n if (typeof propValue === 'string' && isPercent(propValue)) {\n finalValue *= 0.01;\n if (gradientUnits === 'pixels') {\n // then we need to fix those percentages here in svg parsing\n if (prop === 'x1' || prop === 'x2' || prop === 'r2') {\n finalValue *= width;\n }\n if (prop === 'y1' || prop === 'y2') {\n finalValue *= height;\n }\n }\n }\n }\n acc[prop] = finalValue;\n return acc;\n },\n {} as Record,\n );\n}\n\nfunction getValue(el: SVGGradientElement, key: string) {\n return el.getAttribute(key);\n}\n\nexport function parseLinearCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'x1') || 0,\n y1: getValue(el, 'y1') || 0,\n x2: getValue(el, 'x2') || '100%',\n y2: getValue(el, 'y2') || 0,\n };\n}\n\nexport function parseRadialCoords(el: SVGGradientElement) {\n return {\n x1: getValue(el, 'fx') || getValue(el, 'cx') || '50%',\n y1: getValue(el, 'fy') || getValue(el, 'cy') || '50%',\n r1: 0,\n x2: getValue(el, 'cx') || '50%',\n y2: getValue(el, 'cy') || '50%',\n r2: getValue(el, 'r') || '50%',\n };\n}\n\nexport function parseCoords(el: SVGGradientElement, size: TSize) {\n return convertPercentUnitsToValues(\n parseType(el) === 'linear' ? parseLinearCoords(el) : parseRadialCoords(el),\n {\n ...size,\n gradientUnits: parseGradientUnits(el),\n },\n );\n}\n","import { Color } from '../color/Color';\nimport { iMatrix } from '../constants';\nimport { parseTransformAttribute } from '../parser/parseTransformAttribute';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport type { TMat2D } from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { pick } from '../util/misc/pick';\nimport { matrixToSVG } from '../util/misc/svgParsing';\nimport { linearDefaultCoords, radialDefaultCoords } from './constants';\nimport { parseColorStops } from './parser/parseColorStops';\nimport { parseCoords } from './parser/parseCoords';\nimport { parseType, parseGradientUnits } from './parser/misc';\nimport type {\n ColorStop,\n GradientCoords,\n GradientOptions,\n GradientType,\n GradientUnits,\n SVGOptions,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { isPath } from '../util/typeAssertions';\n\n/**\n * Gradient class\n * @class Gradient\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#gradients}\n */\nexport class Gradient<\n S,\n T extends GradientType = S extends GradientType ? S : 'linear',\n> {\n /**\n * Horizontal offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetX: number;\n\n /**\n * Vertical offset for aligning gradients coming from SVG when outside pathgroups\n * @type Number\n * @default 0\n */\n declare offsetY: number;\n\n /**\n * A transform matrix to apply to the gradient before painting.\n * Imported from svg gradients, is not applied with the current transform in the center.\n * Before this transform is applied, the origin point is at the top left corner of the object\n * plus the addition of offsetY and offsetX.\n * @type Number[]\n * @default null\n */\n declare gradientTransform?: TMat2D;\n\n /**\n * coordinates units for coords.\n * If `pixels`, the number of coords are in the same unit of width / height.\n * If set as `percentage` the coords are still a number, but 1 means 100% of width\n * for the X and 100% of the height for the y. It can be bigger than 1 and negative.\n * allowed values pixels or percentage.\n * @type GradientUnits\n * @default 'pixels'\n */\n declare gradientUnits: GradientUnits;\n\n /**\n * Gradient type linear or radial\n * @type GradientType\n * @default 'linear'\n */\n declare type: T;\n\n /**\n * Defines how the gradient is located in space and spread\n * @type GradientCoords\n */\n declare coords: GradientCoords;\n\n /**\n * Defines how many colors a gradient has and how they are located on the axis\n * defined by coords\n * @type GradientCoords\n */\n declare colorStops: ColorStop[];\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number | string\n */\n declare readonly id: string | number;\n\n static type = 'Gradient';\n\n constructor(options: GradientOptions) {\n const {\n type = 'linear' as T,\n gradientUnits = 'pixels',\n coords = {},\n colorStops = [],\n offsetX = 0,\n offsetY = 0,\n gradientTransform,\n id,\n } = options || {};\n Object.assign(this, {\n type,\n gradientUnits,\n coords: {\n ...(type === 'radial' ? radialDefaultCoords : linearDefaultCoords),\n ...coords,\n },\n colorStops,\n offsetX,\n offsetY,\n gradientTransform,\n id: id ? `${id}_${uid()}` : uid(),\n });\n }\n\n /**\n * Adds another colorStop\n * @param {Record} colorStop Object with offset and color\n * @return {Gradient} thisArg\n */\n addColorStop(colorStops: Record) {\n for (const position in colorStops) {\n const color = new Color(colorStops[position]);\n this.colorStops.push({\n offset: parseFloat(position),\n color: color.toRgb(),\n opacity: color.getAlpha(),\n });\n }\n return this;\n }\n\n /**\n * Returns object representation of a gradient\n * @param {string[]} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object}\n */\n toObject(propertiesToInclude?: (keyof this | string)[]) {\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: this.type,\n coords: { ...this.coords },\n colorStops: this.colorStops.map((colorStop) => ({ ...colorStop })),\n offsetX: this.offsetX,\n offsetY: this.offsetY,\n gradientUnits: this.gradientUnits,\n gradientTransform: this.gradientTransform\n ? [...this.gradientTransform]\n : undefined,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of an gradient\n * @param {FabricObject} object Object to create a gradient for\n * @return {String} SVG representation of an gradient (linear/radial)\n */\n toSVG(\n object: FabricObject,\n {\n additionalTransform: preTransform,\n }: { additionalTransform?: string } = {},\n ) {\n const markup = [],\n transform = (\n this.gradientTransform\n ? this.gradientTransform.concat()\n : iMatrix.concat()\n ) as TMat2D,\n gradientUnits =\n this.gradientUnits === 'pixels'\n ? 'userSpaceOnUse'\n : 'objectBoundingBox';\n // colorStops must be sorted ascending, and guarded against deep mutations\n const colorStops = this.colorStops\n .map((colorStop) => ({ ...colorStop }))\n .sort((a, b) => {\n return a.offset - b.offset;\n });\n\n let offsetX = -this.offsetX,\n offsetY = -this.offsetY;\n if (gradientUnits === 'objectBoundingBox') {\n offsetX /= object.width;\n offsetY /= object.height;\n } else {\n offsetX += object.width / 2;\n offsetY += object.height / 2;\n }\n // todo what about polygon/polyline?\n if (isPath(object) && this.gradientUnits !== 'percentage') {\n offsetX -= object.pathOffset.x;\n offsetY -= object.pathOffset.y;\n }\n transform[4] -= offsetX;\n transform[5] -= offsetY;\n\n const commonAttributes = [\n `id=\"SVGID_${this.id}\"`,\n `gradientUnits=\"${gradientUnits}\"`,\n `gradientTransform=\"${\n preTransform ? preTransform + ' ' : ''\n }${matrixToSVG(transform)}\"`,\n '',\n ].join(' ');\n\n if (this.type === 'linear') {\n const { x1, y1, x2, y2 } = this.coords;\n markup.push(\n '\\n',\n );\n } else if (this.type === 'radial') {\n const { x1, y1, x2, y2, r1, r2 } = this\n .coords as GradientCoords<'radial'>;\n const needsSwap = r1 > r2;\n // svg radial gradient has just 1 radius. the biggest.\n markup.push(\n '\\n',\n );\n if (needsSwap) {\n // svg goes from internal to external radius. if radius are inverted, swap color stops.\n colorStops.reverse(); // mutates array\n colorStops.forEach((colorStop) => {\n colorStop.offset = 1 - colorStop.offset;\n });\n }\n const minRadius = Math.min(r1, r2);\n if (minRadius > 0) {\n // i have to shift all colorStops and add new one in 0.\n const maxRadius = Math.max(r1, r2),\n percentageShift = minRadius / maxRadius;\n colorStops.forEach((colorStop) => {\n colorStop.offset += percentageShift * (1 - colorStop.offset);\n });\n }\n }\n\n colorStops.forEach(({ color, offset, opacity }) => {\n markup.push(\n '\\n',\n );\n });\n\n markup.push(\n this.type === 'linear' ? '' : '',\n '\\n',\n );\n\n return markup.join('');\n }\n /* _TO_SVG_END_ */\n\n /**\n * Returns an instance of CanvasGradient\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {CanvasGradient}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasGradient {\n const { x1, y1, x2, y2, r1, r2 } = this.coords as GradientCoords<'radial'>;\n const gradient =\n this.type === 'linear'\n ? ctx.createLinearGradient(x1, y1, x2, y2)\n : ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);\n\n this.colorStops.forEach(({ color, opacity, offset }) => {\n gradient.addColorStop(\n offset,\n typeof opacity !== 'undefined'\n ? new Color(color).setAlpha(opacity).toRgba()\n : color,\n );\n });\n\n return gradient;\n }\n\n static async fromObject(\n options: GradientOptions<'linear'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'radial'>,\n ): Promise>;\n static async fromObject(\n options: GradientOptions<'linear'> | GradientOptions<'radial'>,\n ) {\n const { colorStops, gradientTransform } = options;\n return new this({\n ...options,\n colorStops: colorStops\n ? colorStops.map((colorStop) => ({ ...colorStop }))\n : undefined,\n gradientTransform: gradientTransform ? [...gradientTransform] : undefined,\n });\n }\n\n /* _FROM_SVG_START_ */\n /**\n * Returns {@link Gradient} instance from an SVG element\n * @static\n * @memberOf Gradient\n * @param {SVGGradientElement} el SVG gradient element\n * @param {FabricObject} instance\n * @param {String} opacity A fill-opacity or stroke-opacity attribute to multiply to each stop's opacity.\n * @param {SVGOptions} svgOptions an object containing the size of the SVG in order to parse correctly gradients\n * that uses gradientUnits as 'userSpaceOnUse' and percentages.\n * @return {Gradient} Gradient instance\n * @see http://www.w3.org/TR/SVG/pservers.html#LinearGradientElement\n * @see http://www.w3.org/TR/SVG/pservers.html#RadialGradientElement\n *\n * @example\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n * OR\n *\n * \n * \n * \n * \n * \n *\n */\n static fromElement(\n el: SVGGradientElement,\n instance: FabricObject,\n svgOptions: SVGOptions,\n ): Gradient {\n const gradientUnits = parseGradientUnits(el);\n const center = instance._findCenterFromElement();\n return new this({\n id: el.getAttribute('id') || undefined,\n type: parseType(el),\n coords: parseCoords(el, {\n width: svgOptions.viewBoxWidth || svgOptions.width,\n height: svgOptions.viewBoxHeight || svgOptions.height,\n }),\n colorStops: parseColorStops(el, svgOptions.opacity),\n gradientUnits,\n gradientTransform: parseTransformAttribute(\n el.getAttribute('gradientTransform') || '',\n ),\n ...(gradientUnits === 'pixels'\n ? {\n offsetX: instance.width / 2 - center.x,\n offsetY: instance.height / 2 - center.y,\n }\n : {\n offsetX: 0,\n offsetY: 0,\n }),\n });\n }\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Gradient, 'gradient');\nclassRegistry.setClass(Gradient, 'linear');\nclassRegistry.setClass(Gradient, 'radial');\n","import { config } from '../config';\nimport type { Abortable, TCrossOrigin, TMat2D, TSize } from '../typedefs';\nimport { ifNaN } from '../util/internals/ifNaN';\nimport { uid } from '../util/internals/uid';\nimport { loadImage } from '../util/misc/objectEnlive';\nimport { pick } from '../util/misc/pick';\nimport { toFixed } from '../util/misc/toFixed';\nimport { classRegistry } from '../ClassRegistry';\nimport type {\n PatternRepeat,\n PatternOptions,\n SerializedPatternOptions,\n} from './types';\nimport { log } from '../util/internals/console';\n\n/**\n * @see {@link http://fabricjs.com/patterns demo}\n * @see {@link http://fabricjs.com/dynamic-patterns demo}\n */\nexport class Pattern {\n static type = 'Pattern';\n\n /**\n * Legacy identifier of the class. Prefer using this.constructor.type 'Pattern'\n * or utils like isPattern, or instance of to indentify a pattern in your code.\n * Will be removed in future versiones\n * @TODO add sustainable warning message\n * @type string\n * @deprecated\n */\n get type() {\n return 'pattern';\n }\n\n set type(value) {\n log('warn', 'Setting type has no effect', value);\n }\n\n /**\n * @type PatternRepeat\n * @defaults\n */\n repeat: PatternRepeat = 'repeat';\n\n /**\n * Pattern horizontal offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetX = 0;\n\n /**\n * Pattern vertical offset from object's left/top corner\n * @type Number\n * @default\n */\n offsetY = 0;\n\n /**\n * @type TCrossOrigin\n * @default\n */\n crossOrigin: TCrossOrigin = '';\n\n /**\n * transform matrix to change the pattern, imported from svgs.\n * @todo verify if using the identity matrix as default makes the rest of the code more easy\n * @type Array\n * @default\n */\n declare patternTransform?: TMat2D;\n\n /**\n * The actual pixel source of the pattern\n */\n declare source: CanvasImageSource;\n\n /**\n * If true, this object will not be exported during the serialization of a canvas\n * @type boolean\n */\n declare excludeFromExport?: boolean;\n\n /**\n * ID used for SVG export functionalities\n * @type number\n */\n declare readonly id: number;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n * @param {option.source} [source] the pattern source, eventually empty or a drawable\n */\n constructor(options: PatternOptions) {\n this.id = uid();\n Object.assign(this, options);\n }\n\n /**\n * @returns true if {@link source} is an element\n */\n isImageSource(): this is { source: HTMLImageElement } {\n return (\n !!this.source && typeof (this.source as HTMLImageElement).src === 'string'\n );\n }\n\n /**\n * @returns true if {@link source} is a element\n */\n isCanvasSource(): this is { source: HTMLCanvasElement } {\n return !!this.source && !!(this.source as HTMLCanvasElement).toDataURL;\n }\n\n sourceToString(): string {\n return this.isImageSource()\n ? this.source.src\n : this.isCanvasSource()\n ? this.source.toDataURL()\n : '';\n }\n\n /**\n * Returns an instance of CanvasPattern\n * @param {CanvasRenderingContext2D} ctx Context to create pattern\n * @return {CanvasPattern}\n */\n toLive(ctx: CanvasRenderingContext2D): CanvasPattern | null {\n if (\n // if the image failed to load, return, and allow rest to continue loading\n !this.source ||\n // if an image\n (this.isImageSource() &&\n (!this.source.complete ||\n this.source.naturalWidth === 0 ||\n this.source.naturalHeight === 0))\n ) {\n return null;\n }\n\n return ctx.createPattern(this.source, this.repeat)!;\n }\n\n /**\n * Returns object representation of a pattern\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {object} Object representation of a pattern instance\n */\n toObject(propertiesToInclude: string[] = []): Record {\n const { repeat, crossOrigin } = this;\n return {\n ...pick(this, propertiesToInclude as (keyof this)[]),\n type: 'pattern',\n source: this.sourceToString(),\n repeat,\n crossOrigin,\n offsetX: toFixed(this.offsetX, config.NUM_FRACTION_DIGITS),\n offsetY: toFixed(this.offsetY, config.NUM_FRACTION_DIGITS),\n patternTransform: this.patternTransform\n ? [...this.patternTransform]\n : null,\n };\n }\n\n /* _TO_SVG_START_ */\n /**\n * Returns SVG representation of a pattern\n */\n toSVG({ width, height }: TSize): string {\n const { source: patternSource, repeat, id } = this,\n patternOffsetX = ifNaN(this.offsetX / width, 0),\n patternOffsetY = ifNaN(this.offsetY / height, 0),\n patternWidth =\n repeat === 'repeat-y' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetX || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).width as number) / width,\n 0,\n ),\n patternHeight =\n repeat === 'repeat-x' || repeat === 'no-repeat'\n ? 1 + Math.abs(patternOffsetY || 0)\n : ifNaN(\n ((patternSource as HTMLImageElement).height as number) / height,\n 0,\n );\n\n return [\n ``,\n ``,\n ``,\n '',\n ].join('\\n');\n }\n /* _TO_SVG_END_ */\n\n static async fromObject(\n {\n type,\n source,\n patternTransform,\n ...otherOptions\n }: SerializedPatternOptions,\n options?: Abortable,\n ): Promise {\n const img = await loadImage(source, {\n ...options,\n crossOrigin: otherOptions.crossOrigin,\n });\n return new this({\n ...otherOptions,\n patternTransform:\n patternTransform && (patternTransform.slice(0) as TMat2D),\n source: img,\n });\n }\n}\n\nclassRegistry.setClass(Pattern);\n// kept for compatibility reason\nclassRegistry.setClass(Pattern, 'pattern');\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport type { Shadow } from '../Shadow';\nimport type { Canvas } from '../canvas/Canvas';\nimport type { TBrushEventData } from './typedefs';\n\n/**\n * @see {@link http://fabricjs.com/freedrawing|Freedrawing demo}\n */\nexport abstract class BaseBrush {\n /**\n * Color of a brush\n * @type String\n * @default\n */\n color = 'rgb(0, 0, 0)';\n\n /**\n * Width of a brush, has to be a Number, no string literals\n * @type Number\n * @default\n */\n width = 1;\n\n /**\n * Shadow object representing shadow of this shape.\n * Backwards incompatibility note: This property replaces \"shadowColor\" (String), \"shadowOffsetX\" (Number),\n * \"shadowOffsetY\" (Number) and \"shadowBlur\" (Number) since v1.2.12\n * @type Shadow\n * @default\n */\n shadow: Shadow | null = null;\n\n /**\n * Line endings style of a brush (one of \"butt\", \"round\", \"square\")\n * @type String\n * @default\n */\n strokeLineCap: CanvasLineCap = 'round';\n\n /**\n * Corner style of a brush (one of \"bevel\", \"round\", \"miter\")\n * @type String\n * @default\n */\n strokeLineJoin: CanvasLineJoin = 'round';\n\n /**\n * Maximum miter length (used for strokeLineJoin = \"miter\") of a brush's\n * @type Number\n * @default\n */\n strokeMiterLimit = 10;\n\n /**\n * Stroke Dash Array.\n * @type Array\n * @default\n */\n strokeDashArray: number[] | null = null;\n\n /**\n * When `true`, the free drawing is limited to the whiteboard size. Default to false.\n * @type Boolean\n * @default false\n */\n\n limitedToCanvasSize = false;\n\n /**\n * @todo add type\n */\n declare canvas: Canvas;\n\n constructor(canvas: Canvas) {\n this.canvas = canvas;\n }\n\n abstract _render(): void;\n abstract onMouseDown(pointer: Point, ev: TBrushEventData): void;\n abstract onMouseMove(pointer: Point, ev: TBrushEventData): void;\n /**\n * @returns true if brush should continue blocking interaction\n */\n abstract onMouseUp(ev: TBrushEventData): boolean | void;\n\n /**\n * Sets brush styles\n * @private\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n ctx.strokeStyle = this.color;\n ctx.lineWidth = this.width;\n ctx.lineCap = this.strokeLineCap;\n ctx.miterLimit = this.strokeMiterLimit;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.setLineDash(this.strokeDashArray || []);\n }\n\n /**\n * Sets the transformation on given context\n * @param {CanvasRenderingContext2D} ctx context to render on\n * @private\n */\n protected _saveAndTransform(ctx: CanvasRenderingContext2D) {\n const v = this.canvas.viewportTransform;\n ctx.save();\n ctx.transform(v[0], v[1], v[2], v[3], v[4], v[5]);\n }\n\n protected needsFullRender() {\n const color = new Color(this.color);\n return color.getAlpha() < 1 || !!this.shadow;\n }\n\n /**\n * Sets brush shadow styles\n * @private\n */\n protected _setShadow() {\n if (!this.shadow || !this.canvas) {\n return;\n }\n\n const canvas = this.canvas,\n shadow = this.shadow,\n ctx = canvas.contextTop,\n zoom = canvas.getZoom() * canvas.getRetinaScaling();\n\n ctx.shadowColor = shadow.color;\n ctx.shadowBlur = shadow.blur * zoom;\n ctx.shadowOffsetX = shadow.offsetX * zoom;\n ctx.shadowOffsetY = shadow.offsetY * zoom;\n }\n\n /**\n * Removes brush shadow styles\n * @private\n */\n protected _resetShadow() {\n const ctx = this.canvas.contextTop;\n\n ctx.shadowColor = '';\n ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;\n }\n\n /**\n * Check is pointer is outside canvas boundaries\n * @param {Object} pointer\n * @private\n */\n protected _isOutSideCanvas(pointer: Point) {\n return (\n pointer.x < 0 ||\n pointer.x > this.canvas.getWidth() ||\n pointer.y < 0 ||\n pointer.y > this.canvas.getHeight()\n );\n }\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { toFixed } from '../util/misc/toFixed';\nimport {\n getBoundsOfCurve,\n joinPath,\n makePathSimpler,\n parsePath,\n} from '../util/path';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type {\n TComplexPathData,\n TPathSegmentInfo,\n TSimplePathData,\n} from '../util/path/typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type {\n TBBox,\n TClassProperties,\n TSVGReviver,\n TOptions,\n} from '../typedefs';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\ninterface UniquePathProps {\n sourcePath?: string;\n path?: TSimplePathData;\n}\n\nexport interface SerializedPathProps\n extends SerializedObjectProps,\n UniquePathProps {}\n\nexport interface PathProps extends FabricObjectProps, UniquePathProps {}\n\nexport interface IPathBBox extends TBBox {\n left: number;\n top: number;\n pathOffset: Point;\n}\n\nexport class Path<\n Props extends TOptions = Partial,\n SProps extends SerializedPathProps = SerializedPathProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Array of path points\n * @type Array\n * @default\n */\n declare path: TSimplePathData;\n\n declare pathOffset: Point;\n\n declare sourcePath?: string;\n\n declare segmentsInfo?: TPathSegmentInfo[];\n\n static type = 'Path';\n\n static cacheProperties = [...cacheProperties, 'path', 'fillRule'];\n\n /**\n * Constructor\n * @param {TComplexPathData} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {Partial} [options] Options object\n * @return {Path} thisArg\n */\n constructor(\n path: TComplexPathData | string,\n // todo: evaluate this spread here\n { path: _, left, top, ...options }: Partial = {},\n ) {\n super();\n Object.assign(this, Path.ownDefaults);\n this.setOptions(options);\n this._setPath(path || [], true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {TComplexPathData | string} path Path data (sequence of coordinates and corresponding \"command\" tokens)\n * @param {boolean} [adjustPosition] pass true to reposition the object according to the bounding box\n * @returns {Point} top left position of the bounding box, useful for complementary positioning\n */\n _setPath(path: TComplexPathData | string, adjustPosition?: boolean) {\n this.path = makePathSimpler(Array.isArray(path) ? path : parsePath(path));\n this.setBoundingBox(adjustPosition);\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = this._calcBoundsFromPath();\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _renderPathCommands(ctx: CanvasRenderingContext2D) {\n const l = -this.pathOffset.x,\n t = -this.pathOffset.y;\n\n ctx.beginPath();\n\n for (const command of this.path) {\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n ctx.lineTo(command[1] + l, command[2] + t);\n break;\n\n case 'M': // moveTo, absolute\n ctx.moveTo(command[1] + l, command[2] + t);\n break;\n\n case 'C': // bezierCurveTo, absolute\n ctx.bezierCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n command[5] + l,\n command[6] + t,\n );\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n ctx.quadraticCurveTo(\n command[1] + l,\n command[2] + t,\n command[3] + l,\n command[4] + t,\n );\n break;\n\n case 'Z':\n ctx.closePath();\n break;\n }\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render path on\n */\n _render(ctx: CanvasRenderingContext2D) {\n this._renderPathCommands(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns string representation of an instance\n * @return {string} string representation of an instance\n */\n toString() {\n return `#`;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n path: this.path.map((pathCmd) => pathCmd.slice()),\n };\n }\n\n /**\n * Returns dataless object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toDatalessObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const o = this.toObject(propertiesToInclude);\n if (this.sourcePath) {\n delete o.path;\n o.sourcePath = this.sourcePath;\n }\n return o;\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const path = joinPath(this.path, config.NUM_FRACTION_DIGITS);\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @return the path command's translate transform attribute\n */\n _getOffsetTransform() {\n const digits = config.NUM_FRACTION_DIGITS;\n return ` translate(${toFixed(-this.pathOffset.x, digits)}, ${toFixed(\n -this.pathOffset.y,\n digits,\n )})`;\n }\n\n /**\n * Returns svg clipPath representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toClipPathSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return (\n '\\t' +\n this._createBaseClipPathSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n })\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @param {Function} [reviver] Method for further parsing of svg representation.\n * @return {string} svg representation of an instance\n */\n toSVG(reviver?: TSVGReviver): string {\n const additionalTransform = this._getOffsetTransform();\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n additionalTransform: additionalTransform,\n });\n }\n\n /**\n * Returns number representation of an instance complexity\n * @return {number} complexity of this instance\n */\n complexity() {\n return this.path.length;\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { width, height, pathOffset } = this._calcDimensions();\n this.set({ width, height, pathOffset });\n // using pathOffset because it match the use case.\n // if pathOffset change here we need to use left + width/2 , top + height/2\n adjustPosition && this.setPositionByOrigin(pathOffset, CENTER, CENTER);\n }\n\n _calcBoundsFromPath(): TBBox {\n const bounds: XY[] = [];\n let subpathStartX = 0,\n subpathStartY = 0,\n x = 0, // current x\n y = 0; // current y\n\n for (const command of this.path) {\n // current instruction\n switch (\n command[0] // first letter\n ) {\n case 'L': // lineto, absolute\n x = command[1];\n y = command[2];\n bounds.push({ x: subpathStartX, y: subpathStartY }, { x, y });\n break;\n\n case 'M': // moveTo, absolute\n x = command[1];\n y = command[2];\n subpathStartX = x;\n subpathStartY = y;\n break;\n\n case 'C': // bezierCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[3],\n command[4],\n command[5],\n command[6],\n ),\n );\n x = command[5];\n y = command[6];\n break;\n\n case 'Q': // quadraticCurveTo, absolute\n bounds.push(\n ...getBoundsOfCurve(\n x,\n y,\n command[1],\n command[2],\n command[1],\n command[2],\n command[3],\n command[4],\n ),\n );\n x = command[3];\n y = command[4];\n break;\n\n case 'Z':\n x = subpathStartX;\n y = subpathStartY;\n break;\n }\n }\n return makeBoundingBoxFromPoints(bounds);\n }\n\n /**\n * @private\n */\n _calcDimensions(): IPathBBox {\n const bbox = this._calcBoundsFromPath();\n\n return {\n ...bbox,\n pathOffset: new Point(\n bbox.left + bbox.width / 2,\n bbox.top + bbox.height / 2,\n ),\n };\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by `Path.fromElement`)\n * @static\n * @memberOf Path\n * @see http://www.w3.org/TR/SVG/paths.html#PathElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'd'];\n\n /**\n * Creates an instance of Path from an object\n * @static\n * @memberOf Path\n * @param {Object} object\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'path',\n });\n }\n\n /**\n * Creates an instance of Path from an SVG element\n * @static\n * @memberOf Path\n * @param {HTMLElement} element to parse\n * @param {Partial} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Partial,\n cssRules?: CSSRules,\n ) {\n const { d, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(d, {\n ...parsedAttributes,\n ...options,\n // we pass undefined to instruct the constructor to position the object using the bbox\n left: undefined,\n top: undefined,\n });\n }\n}\n\nclassRegistry.setClass(Path);\nclassRegistry.setSVGClass(Path);\n\n/* _FROM_SVG_START_ */\n","import type { ModifierKey, TEvent } from '../EventTypeDefs';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Path } from '../shapes/Path';\nimport { getSmoothPathFromPoints, joinPath } from '../util/path';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\n/**\n * @private\n * @param {TSimplePathData} pathData SVG path commands\n * @returns {boolean}\n */\nfunction isEmptySVGPath(pathData: TSimplePathData): boolean {\n return joinPath(pathData) === 'M 0 0 Q 0 0 0 0 L 0 0';\n}\n\nexport class PencilBrush extends BaseBrush {\n /**\n * Discard points that are less than `decimate` pixel distant from each other\n * @type Number\n * @default 0.4\n */\n decimate = 0.4;\n\n /**\n * Draws a straight line between last recorded point to current pointer\n * Used for `shift` functionality\n *\n * @type boolean\n * @default false\n */\n drawStraightLine = false;\n\n /**\n * The event modifier key that makes the brush draw a straight line.\n * If `null` or 'none' or any other string that is not a modifier key the feature is disabled.\n * @type {ModifierKey | undefined | null}\n */\n straightLineKey: ModifierKey | undefined | null = 'shiftKey';\n\n private declare _points: Point[];\n private declare _hasStraightLine: boolean;\n private declare oldEnd?: Point;\n\n constructor(canvas: Canvas) {\n super(canvas);\n this._points = [];\n this._hasStraightLine = false;\n }\n\n needsFullRender() {\n return super.needsFullRender() || this._hasStraightLine;\n }\n\n static drawSegment(ctx: CanvasRenderingContext2D, p1: Point, p2: Point) {\n const midPoint = p1.midPointFrom(p2);\n ctx.quadraticCurveTo(p1.x, p1.y, midPoint.x, midPoint.y);\n return midPoint;\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n this._prepareForDrawing(pointer);\n // capture coordinates immediately\n // this allows to draw dots (when movement never occurs)\n this._addPoint(pointer);\n this._render();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point, { e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return;\n }\n this.drawStraightLine = !!this.straightLineKey && e[this.straightLineKey];\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this._addPoint(pointer) && this._points.length > 1) {\n if (this.needsFullRender()) {\n // redraw curve\n // clear top canvas\n this.canvas.clearContext(this.canvas.contextTop);\n this._render();\n } else {\n const points = this._points,\n length = points.length,\n ctx = this.canvas.contextTop;\n // draw the curve update\n this._saveAndTransform(ctx);\n if (this.oldEnd) {\n ctx.beginPath();\n ctx.moveTo(this.oldEnd.x, this.oldEnd.y);\n }\n this.oldEnd = PencilBrush.drawSegment(\n ctx,\n points[length - 2],\n points[length - 1],\n );\n ctx.stroke();\n ctx.restore();\n }\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp({ e }: TEvent) {\n if (!this.canvas._isMainEvent(e)) {\n return true;\n }\n this.drawStraightLine = false;\n this.oldEnd = undefined;\n this._finalizeAndAddPath();\n return false;\n }\n\n /**\n * @private\n * @param {Point} pointer Actual mouse position related to the canvas.\n */\n _prepareForDrawing(pointer: Point) {\n this._reset();\n this._addPoint(pointer);\n this.canvas.contextTop.moveTo(pointer.x, pointer.y);\n }\n\n /**\n * @private\n * @param {Point} point Point to be added to points array\n */\n _addPoint(point: Point) {\n if (\n this._points.length > 1 &&\n point.eq(this._points[this._points.length - 1])\n ) {\n return false;\n }\n if (this.drawStraightLine && this._points.length > 1) {\n this._hasStraightLine = true;\n this._points.pop();\n }\n this._points.push(point);\n return true;\n }\n\n /**\n * Clear points array and set contextTop canvas style.\n * @private\n */\n _reset() {\n this._points = [];\n this._setBrushStyles(this.canvas.contextTop);\n this._setShadow();\n this._hasStraightLine = false;\n }\n\n /**\n * Draw a smooth path on the topCanvas using quadraticCurveTo\n * @private\n * @param {CanvasRenderingContext2D} [ctx]\n */\n _render(ctx: CanvasRenderingContext2D = this.canvas.contextTop) {\n let p1 = this._points[0],\n p2 = this._points[1];\n this._saveAndTransform(ctx);\n ctx.beginPath();\n //if we only have 2 points in the path and they are the same\n //it means that the user only clicked the canvas without moving the mouse\n //then we should be drawing a dot. A path isn't drawn between two identical dots\n //that's why we set them apart a bit\n if (this._points.length === 2 && p1.x === p2.x && p1.y === p2.y) {\n const width = this.width / 1000;\n p1.x -= width;\n p2.x += width;\n }\n ctx.moveTo(p1.x, p1.y);\n\n for (let i = 1; i < this._points.length; i++) {\n // we pick the point between pi + 1 & pi + 2 as the\n // end point and p1 as our control point.\n PencilBrush.drawSegment(ctx, p1, p2);\n p1 = this._points[i];\n p2 = this._points[i + 1];\n }\n // Draw last line as a straight line while\n // we wait for the next point to be able to calculate\n // the bezier control point\n ctx.lineTo(p1.x, p1.y);\n ctx.stroke();\n ctx.restore();\n }\n\n /**\n * Converts points to SVG path\n * @param {Point[]} points Array of points\n * @return {TSimplePathData} SVG path commands\n */\n convertPointsToSVGPath(points: Point[]): TSimplePathData {\n const correction = this.width / 1000;\n return getSmoothPathFromPoints(points, correction);\n }\n\n /**\n * Creates a Path object to add on canvas\n * @param {TSimplePathData} pathData Path data\n * @return {Path} Path to add on canvas\n */\n createPath(pathData: TSimplePathData): Path {\n const path = new Path(pathData, {\n fill: null,\n stroke: this.color,\n strokeWidth: this.width,\n strokeLineCap: this.strokeLineCap,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeLineJoin: this.strokeLineJoin,\n strokeDashArray: this.strokeDashArray,\n });\n if (this.shadow) {\n this.shadow.affectStroke = true;\n path.shadow = new Shadow(this.shadow);\n }\n\n return path;\n }\n\n /**\n * Decimate points array with the decimate value\n */\n decimatePoints(points: Point[], distance: number) {\n if (points.length <= 2) {\n return points;\n }\n let lastPoint = points[0],\n cDistance;\n const zoom = this.canvas.getZoom(),\n adjustedDistance = Math.pow(distance / zoom, 2),\n l = points.length - 1,\n newPoints = [lastPoint];\n for (let i = 1; i < l - 1; i++) {\n cDistance =\n Math.pow(lastPoint.x - points[i].x, 2) +\n Math.pow(lastPoint.y - points[i].y, 2);\n if (cDistance >= adjustedDistance) {\n lastPoint = points[i];\n newPoints.push(lastPoint);\n }\n }\n // Add the last point from the original line to the end of the array.\n // This ensures decimate doesn't delete the last point on the line, and ensures the line is > 1 point.\n newPoints.push(points[l]);\n return newPoints;\n }\n\n /**\n * On mouseup after drawing the path on contextTop canvas\n * we use the points captured to create an new Path object\n * and add it to the canvas.\n */\n _finalizeAndAddPath() {\n const ctx = this.canvas.contextTop;\n ctx.closePath();\n if (this.decimate) {\n this._points = this.decimatePoints(this._points, this.decimate);\n }\n const pathData = this.convertPointsToSVGPath(this._points);\n if (isEmptySVGPath(pathData)) {\n // do not create 0 width/height paths, as they are\n // rendered inconsistently across browsers\n // Firefox 4, for example, renders a dot,\n // whereas Chrome 10 renders nothing\n this.canvas.requestRenderAll();\n return;\n }\n\n const path = this.createPath(pathData);\n this.canvas.clearContext(this.canvas.contextTop);\n this.canvas.fire('before:path:created', { path: path });\n this.canvas.add(path);\n this.canvas.requestRenderAll();\n path.setCoords();\n this._resetShadow();\n\n // fire event 'path' created\n this.canvas.fire('path:created', { path: path });\n }\n}\n","import type { ObjectEvents } from '../EventTypeDefs';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { cos } from '../util/misc/cos';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { sin } from '../util/misc/sin';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { CSSRules } from '../parser/typedefs';\nimport { SCALE_X, SCALE_Y } from '../constants';\n\ninterface UniqueCircleProps {\n /**\n * Radius of this circle\n * @type Number\n * @default 0\n */\n radius: number;\n\n /**\n * Angle for the start of the circle, in degrees.\n * @type TDegree 0 - 359\n * @default 0\n */\n startAngle: number;\n\n /**\n * Angle for the end of the circle, in degrees\n * @type TDegree 1 - 360\n * @default 360\n */\n endAngle: number;\n\n /**\n * Orientation for the direction of the circle.\n * Setting to true will switch the arc of the circle to traverse from startAngle to endAngle in a counter-clockwise direction.\n * Note: this will only change how the circle is drawn, and does not affect rotational transformation.\n * @default false\n */\n counterClockwise: boolean;\n}\n\nexport interface SerializedCircleProps\n extends SerializedObjectProps,\n UniqueCircleProps {}\n\nexport interface CircleProps extends FabricObjectProps, UniqueCircleProps {}\n\nconst CIRCLE_PROPS = [\n 'radius',\n 'startAngle',\n 'endAngle',\n 'counterClockwise',\n] as const;\n\nexport const circleDefaultValues: Partial> = {\n radius: 0,\n startAngle: 0,\n endAngle: 360,\n counterClockwise: false,\n};\n\nexport class Circle<\n Props extends TOptions = Partial,\n SProps extends SerializedCircleProps = SerializedCircleProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueCircleProps\n{\n declare radius: number;\n declare startAngle: number;\n declare endAngle: number;\n declare counterClockwise: boolean;\n\n static type = 'Circle';\n\n static cacheProperties = [...cacheProperties, ...CIRCLE_PROPS];\n\n static ownDefaults = circleDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Circle.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Circle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n\n if (key === 'radius') {\n this.setRadius(value);\n }\n\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.arc(\n 0,\n 0,\n this.radius,\n degreesToRadians(this.startAngle),\n degreesToRadians(this.endAngle),\n this.counterClockwise,\n );\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusX(): number {\n return this.get('radius') * this.get(SCALE_X);\n }\n\n /**\n * Returns vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRadiusY(): number {\n return this.get('radius') * this.get(SCALE_Y);\n }\n\n /**\n * Sets radius of an object (and updates width accordingly)\n */\n setRadius(value: number) {\n this.radius = value;\n this.set({ width: value * 2, height: value * 2 });\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...CIRCLE_PROPS, ...propertiesToInclude]);\n }\n\n /* _TO_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n const angle = (this.endAngle - this.startAngle) % 360;\n\n if (angle === 0) {\n return [\n '\\n',\n ];\n } else {\n const { radius } = this;\n const start = degreesToRadians(this.startAngle),\n end = degreesToRadians(this.endAngle),\n startX = cos(start) * radius,\n startY = sin(start) * radius,\n endX = cos(end) * radius,\n endY = sin(end) * radius,\n largeFlag = angle > 180 ? 1 : 0,\n sweepFlag = this.counterClockwise ? 0 : 1;\n return [\n `\\n',\n ];\n }\n }\n /* _TO_SVG_END_ */\n\n /* _FROM_SVG_START_ */\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Circle.fromElement})\n * @static\n * @memberOf Circle\n * @see: http://www.w3.org/TR/SVG/shapes.html#CircleElement\n */\n static ATTRIBUTE_NAMES = ['cx', 'cy', 'r', ...SHARED_ATTRIBUTES];\n\n /**\n * Returns {@link Circle} instance from an SVG element\n * @static\n * @memberOf Circle\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Partial Circle object to default missing properties on the element.\n * @throws {Error} If value of `r` attribute is missing or invalid\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ): Promise {\n const {\n left = 0,\n top = 0,\n radius = 0,\n ...otherParsedAttributes\n } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n ) as Partial;\n\n // this probably requires to be fixed for default origins not being top/left.\n\n return new this({\n ...otherParsedAttributes,\n radius,\n left: left - radius,\n top: top - radius,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * @todo how do we declare this??\n */\n static fromObject>(object: T) {\n return super._fromObject(object);\n }\n}\n\nclassRegistry.setClass(Circle);\nclassRegistry.setSVGClass(Circle);\n","import { Color } from '../color/Color';\nimport type { Point } from '../Point';\nimport { Shadow } from '../Shadow';\nimport { Circle } from '../shapes/Circle';\nimport { Group } from '../shapes/Group';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { CircleBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\nexport class CircleBrush extends BaseBrush {\n /**\n * Width of a brush\n * @type Number\n * @default\n */\n width = 10;\n\n declare points: CircleBrushPoint[];\n\n constructor(canvas: Canvas) {\n super(canvas);\n this.points = [];\n }\n\n /**\n * Invoked inside on mouse down and mouse move\n * @param {Point} pointer\n */\n drawDot(pointer: Point) {\n const point = this.addPoint(pointer),\n ctx = this.canvas.contextTop;\n this._saveAndTransform(ctx);\n this.dot(ctx, point);\n ctx.restore();\n }\n\n dot(ctx: CanvasRenderingContext2D, point: CircleBrushPoint) {\n ctx.fillStyle = point.fill;\n ctx.beginPath();\n ctx.arc(point.x, point.y, point.radius, 0, Math.PI * 2, false);\n ctx.closePath();\n ctx.fill();\n }\n\n /**\n * Invoked on mouse down\n */\n onMouseDown(pointer: Point) {\n this.points = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n this.drawDot(pointer);\n }\n\n /**\n * Render the full state of the brush\n * @private\n */\n _render() {\n const ctx = this.canvas.contextTop,\n points = this.points;\n this._saveAndTransform(ctx);\n for (let i = 0; i < points.length; i++) {\n this.dot(ctx, points[i]);\n }\n ctx.restore();\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n if (this.needsFullRender()) {\n this.canvas.clearContext(this.canvas.contextTop);\n this.addPoint(pointer);\n this._render();\n } else {\n this.drawDot(pointer);\n }\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const circles: Circle[] = [];\n\n for (let i = 0; i < this.points.length; i++) {\n const point = this.points[i],\n circle = new Circle({\n radius: point.radius,\n left: point.x,\n top: point.y,\n originX: CENTER,\n originY: CENTER,\n fill: point.fill,\n });\n\n this.shadow && (circle.shadow = new Shadow(this.shadow));\n\n circles.push(circle);\n }\n const group = new Group(circles, { canvas: this.canvas });\n\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n /**\n * @param {Object} pointer\n * @return {Point} Just added pointer point\n */\n addPoint({ x, y }: Point) {\n const pointerPoint: CircleBrushPoint = {\n x,\n y,\n radius: getRandomInt(Math.max(0, this.width - 20), this.width + 20) / 2,\n fill: new Color(this.color).setAlpha(getRandomInt(0, 100) / 100).toRgba(),\n };\n\n this.points.push(pointerPoint);\n\n return pointerPoint;\n }\n}\n","import type { Point } from '../Point';\nimport { Group } from '../shapes/Group';\nimport { Shadow } from '../Shadow';\nimport { Rect } from '../shapes/Rect';\nimport { getRandomInt } from '../util/internals/getRandomInt';\nimport type { Canvas } from '../canvas/Canvas';\nimport { BaseBrush } from './BaseBrush';\nimport type { SprayBrushPoint } from './typedefs';\nimport { CENTER } from '../constants';\n\n/**\n *\n * @param rects\n * @returns\n */\nfunction getUniqueRects(rects: Rect[]) {\n const uniqueRects: Record = {};\n const uniqueRectsArray: Rect[] = [];\n\n for (let i = 0, key: string; i < rects.length; i++) {\n key = `${rects[i].left}${rects[i].top}`;\n if (!uniqueRects[key]) {\n uniqueRects[key] = true;\n uniqueRectsArray.push(rects[i]);\n }\n }\n\n return uniqueRectsArray;\n}\n\nexport class SprayBrush extends BaseBrush {\n /**\n * Width of a spray\n * @type Number\n * @default\n */\n width = 10;\n\n /**\n * Density of a spray (number of dots per chunk)\n * @type Number\n * @default\n */\n density = 20;\n\n /**\n * Width of spray dots\n * @type Number\n * @default\n */\n dotWidth = 1;\n\n /**\n * Width variance of spray dots\n * @type Number\n * @default\n */\n dotWidthVariance = 1;\n\n /**\n * Whether opacity of a dot should be random\n * @type Boolean\n * @default\n */\n randomOpacity = false;\n\n /**\n * Whether overlapping dots (rectangles) should be removed (for performance reasons)\n * @type Boolean\n * @default\n */\n optimizeOverlapping = true;\n\n private declare sprayChunks: SprayBrushPoint[][];\n\n private declare sprayChunk: SprayBrushPoint[];\n\n /**\n * Constructor\n * @param {Canvas} canvas\n * @return {SprayBrush} Instance of a spray brush\n */\n constructor(canvas: Canvas) {\n super(canvas);\n this.sprayChunks = [];\n this.sprayChunk = [];\n }\n\n /**\n * Invoked on mouse down\n * @param {Point} pointer\n */\n onMouseDown(pointer: Point) {\n this.sprayChunks = [];\n this.canvas.clearContext(this.canvas.contextTop);\n this._setShadow();\n\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse move\n * @param {Point} pointer\n */\n onMouseMove(pointer: Point) {\n if (this.limitedToCanvasSize === true && this._isOutSideCanvas(pointer)) {\n return;\n }\n this.addSprayChunk(pointer);\n this.renderChunck(this.sprayChunk);\n }\n\n /**\n * Invoked on mouse up\n */\n onMouseUp() {\n const originalRenderOnAddRemove = this.canvas.renderOnAddRemove;\n this.canvas.renderOnAddRemove = false;\n\n const rects: Rect[] = [];\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n const sprayChunk = this.sprayChunks[i];\n for (let j = 0; j < sprayChunk.length; j++) {\n const chunck = sprayChunk[j];\n const rect = new Rect({\n width: chunck.width,\n height: chunck.width,\n left: chunck.x + 1,\n top: chunck.y + 1,\n originX: CENTER,\n originY: CENTER,\n fill: this.color,\n });\n rects.push(rect);\n }\n }\n\n const group = new Group(\n this.optimizeOverlapping ? getUniqueRects(rects) : rects,\n {\n objectCaching: true,\n subTargetCheck: false,\n interactive: false,\n },\n );\n this.shadow && group.set('shadow', new Shadow(this.shadow));\n this.canvas.fire('before:path:created', { path: group });\n this.canvas.add(group);\n this.canvas.fire('path:created', { path: group });\n\n this.canvas.clearContext(this.canvas.contextTop);\n this._resetShadow();\n this.canvas.renderOnAddRemove = originalRenderOnAddRemove;\n this.canvas.requestRenderAll();\n }\n\n renderChunck(sprayChunck: SprayBrushPoint[]) {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < sprayChunck.length; i++) {\n const point = sprayChunck[i];\n ctx.globalAlpha = point.opacity;\n ctx.fillRect(point.x, point.y, point.width, point.width);\n }\n\n ctx.restore();\n }\n\n /**\n * Render all spray chunks\n */\n _render() {\n const ctx = this.canvas.contextTop;\n ctx.fillStyle = this.color;\n\n this._saveAndTransform(ctx);\n\n for (let i = 0; i < this.sprayChunks.length; i++) {\n this.renderChunck(this.sprayChunks[i]);\n }\n ctx.restore();\n }\n\n /**\n * @param {Point} pointer\n */\n addSprayChunk(pointer: Point) {\n this.sprayChunk = [];\n const radius = this.width / 2;\n\n for (let i = 0; i < this.density; i++) {\n this.sprayChunk.push({\n x: getRandomInt(pointer.x - radius, pointer.x + radius),\n y: getRandomInt(pointer.y - radius, pointer.y + radius),\n width: this.dotWidthVariance\n ? getRandomInt(\n // bottom clamp width to 1\n Math.max(1, this.dotWidth - this.dotWidthVariance),\n this.dotWidth + this.dotWidthVariance,\n )\n : this.dotWidth,\n opacity: this.randomOpacity ? getRandomInt(0, 100) / 100 : 1,\n });\n }\n\n this.sprayChunks.push(this.sprayChunk);\n }\n}\n","import { Pattern } from '../Pattern';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { Canvas } from '../canvas/Canvas';\nimport { PencilBrush } from './PencilBrush';\nimport type { TSimplePathData } from '../util/path/typedefs';\n\nexport class PatternBrush extends PencilBrush {\n declare source?: CanvasImageSource;\n\n constructor(canvas: Canvas) {\n super(canvas);\n }\n\n getPatternSrc() {\n const dotWidth = 20,\n dotDistance = 5,\n patternCanvas = createCanvasElement(),\n patternCtx = patternCanvas.getContext('2d');\n\n patternCanvas.width = patternCanvas.height = dotWidth + dotDistance;\n if (patternCtx) {\n patternCtx.fillStyle = this.color;\n patternCtx.beginPath();\n patternCtx.arc(\n dotWidth / 2,\n dotWidth / 2,\n dotWidth / 2,\n 0,\n Math.PI * 2,\n false,\n );\n patternCtx.closePath();\n patternCtx.fill();\n }\n return patternCanvas;\n }\n\n /**\n * Creates \"pattern\" instance property\n * @param {CanvasRenderingContext2D} ctx\n */\n getPattern(ctx: CanvasRenderingContext2D) {\n return ctx.createPattern(this.source || this.getPatternSrc(), 'repeat');\n }\n\n /**\n * Sets brush styles\n * @param {CanvasRenderingContext2D} ctx\n */\n _setBrushStyles(ctx: CanvasRenderingContext2D) {\n super._setBrushStyles(ctx);\n const pattern = this.getPattern(ctx);\n pattern && (ctx.strokeStyle = pattern);\n }\n\n /**\n * Creates path\n */\n createPath(pathData: TSimplePathData) {\n const path = super.createPath(pathData),\n topLeft = path._getLeftTopCoords().scalarAdd(path.strokeWidth / 2);\n\n path.stroke = new Pattern({\n source: this.source || this.getPatternSrc(),\n offsetX: -topLeft.x,\n offsetY: -topLeft.y,\n });\n return path;\n }\n}\n","import { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport { Point } from '../Point';\nimport { isFiller } from '../util/typeAssertions';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { makeBoundingBoxFromPoints } from '../util';\nimport { CENTER, LEFT, TOP } from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\n// @TODO this code is terrible and Line should be a special case of polyline.\n\nconst coordProps = ['x1', 'x2', 'y1', 'y2'] as const;\n\ninterface UniqueLineProps {\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n}\n\nexport interface SerializedLineProps\n extends SerializedObjectProps,\n UniqueLineProps {}\n\nexport class Line<\n Props extends TOptions = Partial,\n SProps extends SerializedLineProps = SerializedLineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements UniqueLineProps\n{\n /**\n * x value or first line edge\n * @type number\n * @default\n */\n declare x1: number;\n\n /**\n * y value or first line edge\n * @type number\n * @default\n */\n declare y1: number;\n\n /**\n * x value or second line edge\n * @type number\n * @default\n */\n declare x2: number;\n\n /**\n * y value or second line edge\n * @type number\n * @default\n */\n declare y2: number;\n\n static type = 'Line';\n\n static cacheProperties = [...cacheProperties, ...coordProps];\n /**\n * Constructor\n * @param {Array} [points] Array of points\n * @param {Object} [options] Options object\n * @return {Line} thisArg\n */\n constructor([x1, y1, x2, y2] = [0, 0, 0, 0], options: Partial = {}) {\n super();\n Object.assign(this, Line.ownDefaults);\n this.setOptions(options);\n this.x1 = x1;\n this.x2 = x2;\n this.y1 = y1;\n this.y2 = y2;\n this._setWidthHeight();\n const { left, top } = options;\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n /**\n * @private\n * @param {Object} [options] Options\n */\n _setWidthHeight() {\n const { x1, y1, x2, y2 } = this;\n this.width = Math.abs(x2 - x1);\n this.height = Math.abs(y2 - y1);\n const { left, top, width, height } = makeBoundingBoxFromPoints([\n { x: x1, y: y1 },\n { x: x2, y: y2 },\n ]);\n const position = new Point(left + width / 2, top + height / 2);\n this.setPositionByOrigin(position, CENTER, CENTER);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n super._set(key, value);\n if (coordProps.includes(key as keyof UniqueLineProps)) {\n // this doesn't make sense very much, since setting x1 when top or left\n // are already set, is just going to show a strange result since the\n // line will move way more than the developer expect.\n // in fabric5 it worked only when the line didn't have extra transformations,\n // in fabric6 too. With extra transform they behave bad in different ways.\n // This needs probably a good rework or a tutorial if you have to create a dynamic line\n this._setWidthHeight();\n }\n return this;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n\n const p = this.calcLinePoints();\n ctx.moveTo(p.x1, p.y1);\n ctx.lineTo(p.x2, p.y2);\n\n ctx.lineWidth = this.strokeWidth;\n\n // TODO: test this\n // make sure setting \"fill\" changes color of a line\n // (by copying fillStyle to strokeStyle, since line is stroked, not filled)\n const origStrokeStyle = ctx.strokeStyle;\n if (isFiller(this.stroke)) {\n ctx.strokeStyle = this.stroke.toLive(ctx)!;\n } else {\n ctx.strokeStyle = this.stroke ?? ctx.fillStyle;\n }\n this.stroke && this._renderStroke(ctx);\n ctx.strokeStyle = origStrokeStyle;\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n return new Point((this.x1 + this.x2) / 2, (this.y1 + this.y2) / 2);\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n ...this.calcLinePoints(),\n };\n }\n\n /*\n * Calculate object dimensions from its properties\n * @private\n */\n _getNonTransformedDimensions(): Point {\n const dim = super._getNonTransformedDimensions();\n if (this.strokeLineCap === 'butt') {\n if (this.width === 0) {\n dim.y -= this.strokeWidth;\n }\n if (this.height === 0) {\n dim.x -= this.strokeWidth;\n }\n }\n return dim;\n }\n\n /**\n * Recalculates line points given width and height\n * Those points are simply placed around the center,\n * This is not useful outside internal render functions and svg output\n * Is not meant to be for the developer.\n * @private\n */\n calcLinePoints(): UniqueLineProps {\n const { x1: _x1, x2: _x2, y1: _y1, y2: _y2, width, height } = this;\n const xMult = _x1 <= _x2 ? -1 : 1,\n yMult = _y1 <= _y2 ? -1 : 1,\n x1 = (xMult * width) / 2,\n y1 = (yMult * height) / 2,\n x2 = (xMult * -width) / 2,\n y2 = (yMult * -height) / 2;\n\n return {\n x1,\n x2,\n y1,\n y2,\n };\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const { x1, x2, y1, y2 } = this.calcLinePoints();\n return [\n '\\n`,\n ];\n }\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Line.fromElement})\n * @static\n * @memberOf Line\n * @see http://www.w3.org/TR/SVG/shapes.html#LineElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(coordProps);\n\n /**\n * Returns Line instance from an SVG element\n * @static\n * @memberOf Line\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {Function} [callback] callback function invoked after parsing\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const {\n x1 = 0,\n y1 = 0,\n x2 = 0,\n y2 = 0,\n ...parsedAttributes\n } = parseAttributes(element, this.ATTRIBUTE_NAMES, cssRules);\n return new this([x1, y1, x2, y2], parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Line instance from an object representation\n * @static\n * @memberOf Line\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>({\n x1,\n y1,\n x2,\n y2,\n ...object\n }: T) {\n return this._fromObject(\n {\n ...object,\n points: [x1, y1, x2, y2],\n },\n {\n extraParam: 'points',\n },\n );\n }\n}\n\nclassRegistry.setClass(Line);\nclassRegistry.setSVGClass(Line);\n","import { classRegistry } from '../ClassRegistry';\nimport { FabricObject } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { TClassProperties, TOptions } from '../typedefs';\nimport type { ObjectEvents } from '../EventTypeDefs';\n\nexport const triangleDefaultValues: Partial> = {\n width: 100,\n height: 100,\n};\n\nexport class Triangle<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements FabricObjectProps\n{\n static type = 'Triangle';\n\n static ownDefaults = triangleDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...Triangle.ownDefaults };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Triangle.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2;\n\n ctx.beginPath();\n ctx.moveTo(-widthBy2, heightBy2);\n ctx.lineTo(0, -heightBy2);\n ctx.lineTo(widthBy2, heightBy2);\n ctx.closePath();\n\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const widthBy2 = this.width / 2,\n heightBy2 = this.height / 2,\n points = `${-widthBy2} ${heightBy2},0 ${-heightBy2},${widthBy2} ${heightBy2}`;\n return [''];\n }\n}\n\nclassRegistry.setClass(Triangle);\nclassRegistry.setSVGClass(Triangle);\n","import { SCALE_X, SCALE_Y, twoMathPi } from '../constants';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const ellipseDefaultValues: Partial> = {\n rx: 0,\n ry: 0,\n};\n\ninterface UniqueEllipseProps {\n rx: number;\n ry: number;\n}\n\nexport interface SerializedEllipseProps\n extends SerializedObjectProps,\n UniqueEllipseProps {}\n\nexport interface EllipseProps extends FabricObjectProps, UniqueEllipseProps {}\n\nconst ELLIPSE_PROPS = ['rx', 'ry'] as const;\n\nexport class Ellipse<\n Props extends TOptions = Partial,\n SProps extends SerializedEllipseProps = SerializedEllipseProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements EllipseProps\n{\n /**\n * Horizontal radius\n * @type Number\n * @default\n */\n declare rx: number;\n\n /**\n * Vertical radius\n * @type Number\n * @default\n */\n declare ry: number;\n\n static type = 'Ellipse';\n\n static cacheProperties = [...cacheProperties, ...ELLIPSE_PROPS];\n\n static ownDefaults = ellipseDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Ellipse.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor(options?: Props) {\n super();\n Object.assign(this, Ellipse.ownDefaults);\n this.setOptions(options);\n }\n\n /**\n * @private\n * @param {String} key\n * @param {*} value\n * @return {Ellipse} thisArg\n */\n _set(key: string, value: any) {\n super._set(key, value);\n switch (key) {\n case 'rx':\n this.rx = value;\n this.set('width', value * 2);\n break;\n\n case 'ry':\n this.ry = value;\n this.set('height', value * 2);\n break;\n }\n return this;\n }\n\n /**\n * Returns horizontal radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRx() {\n return this.get('rx') * this.get(SCALE_X);\n }\n\n /**\n * Returns Vertical radius of an object (according to how an object is scaled)\n * @return {Number}\n */\n getRy() {\n return this.get('ry') * this.get(SCALE_Y);\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([...ELLIPSE_PROPS, ...propertiesToInclude]);\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG(): string[] {\n return [\n '\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.beginPath();\n ctx.save();\n ctx.transform(1, 0, 0, this.ry / this.rx, 0, 0);\n ctx.arc(0, 0, this.rx, 0, twoMathPi, false);\n ctx.restore();\n this._renderPaintInOrder(ctx);\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Ellipse.fromElement})\n * @static\n * @memberOf Ellipse\n * @see http://www.w3.org/TR/SVG/shapes.html#EllipseElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES, 'cx', 'cy', 'rx', 'ry'];\n\n /**\n * Returns {@link Ellipse} instance from an SVG element\n * @static\n * @memberOf Ellipse\n * @param {HTMLElement} element Element to parse\n * @return {Ellipse}\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n parsedAttributes.left = (parsedAttributes.left || 0) - parsedAttributes.rx;\n parsedAttributes.top = (parsedAttributes.top || 0) - parsedAttributes.ry;\n return new this(parsedAttributes);\n }\n\n /* _FROM_SVG_END_ */\n}\n\nclassRegistry.setClass(Ellipse);\nclassRegistry.setSVGClass(Ellipse);\n","import type { XY } from '../Point';\n\n/**\n * Parses \"points\" attribute, returning an array of values\n * @static\n * @memberOf fabric\n * @param {String} points points attribute string\n * @return {Array} array of points\n */\nexport function parsePointsAttribute(points: string | null): XY[] {\n // points attribute is required and must not be empty\n if (!points) {\n return [];\n }\n\n // replace commas with whitespace and remove bookending whitespace\n const pointsSplit: string[] = points.replace(/,/g, ' ').trim().split(/\\s+/);\n\n const parsedPoints = [];\n\n for (let i = 0; i < pointsSplit.length; i += 2) {\n parsedPoints.push({\n x: parseFloat(pointsSplit[i]),\n y: parseFloat(pointsSplit[i + 1]),\n });\n }\n\n // odd number of points is an error\n // if (parsedPoints.length % 2 !== 0) {\n // return null;\n // }\n return parsedPoints;\n}\n","import { config } from '../config';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport { parsePointsAttribute } from '../parser/parsePointsAttribute';\nimport type { XY } from '../Point';\nimport { Point } from '../Point';\nimport type { Abortable, TClassProperties, TOptions } from '../typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { makeBoundingBoxFromPoints } from '../util/misc/boundingBoxFromPoints';\nimport { calcDimensionsMatrix, transformPoint } from '../util/misc/matrix';\nimport { projectStrokeOnPoints } from '../util/misc/projectStroke';\nimport type { TProjectStrokeOnPointsOptions } from '../util/misc/projectStroke/types';\nimport { degreesToRadians } from '../util/misc/radiansDegreesConversion';\nimport { toFixed } from '../util/misc/toFixed';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport {\n CENTER,\n LEFT,\n SCALE_X,\n SCALE_Y,\n SKEW_X,\n SKEW_Y,\n TOP,\n} from '../constants';\nimport type { CSSRules } from '../parser/typedefs';\n\nexport const polylineDefaultValues: Partial> = {\n /**\n * @deprecated transient option soon to be removed in favor of a different design\n */\n exactBoundingBox: false,\n};\n\nexport interface SerializedPolylineProps extends SerializedObjectProps {\n points: XY[];\n}\n\nexport class Polyline<\n Props extends TOptions = Partial,\n SProps extends SerializedPolylineProps = SerializedPolylineProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n /**\n * Points array\n * @type Array\n * @default\n */\n declare points: XY[];\n\n /**\n * WARNING: Feature in progress\n * Calculate the exact bounding box taking in account strokeWidth on acute angles\n * this will be turned to true by default on fabric 6.0\n * maybe will be left in as an optimization since calculations may be slow\n * @deprecated transient option soon to be removed in favor of a different design\n * @type Boolean\n * @default false\n */\n declare exactBoundingBox: boolean;\n\n private declare initialized: true | undefined;\n\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polyline';\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Polyline.ownDefaults,\n };\n }\n\n /**\n * A list of properties that if changed trigger a recalculation of dimensions\n * @todo check if you really need to recalculate for all cases\n */\n static layoutProperties: (keyof Polyline)[] = [\n SKEW_X,\n SKEW_Y,\n 'strokeLineCap',\n 'strokeLineJoin',\n 'strokeMiterLimit',\n 'strokeWidth',\n 'strokeUniform',\n 'points',\n ];\n\n declare pathOffset: Point;\n\n declare strokeOffset: Point;\n\n static cacheProperties = [...cacheProperties, 'points'];\n\n strokeDiff: Point;\n\n /**\n * Constructor\n * @param {Array} points Array of points (where each point is an object with x and y)\n * @param {Object} [options] Options object\n * @return {Polyline} thisArg\n * @example\n * var poly = new Polyline([\n * { x: 10, y: 10 },\n * { x: 50, y: 30 },\n * { x: 40, y: 70 },\n * { x: 60, y: 50 },\n * { x: 100, y: 150 },\n * { x: 40, y: 100 }\n * ], {\n * stroke: 'red',\n * left: 100,\n * top: 100\n * });\n */\n constructor(points: XY[] = [], options: Props = {} as Props) {\n super();\n Object.assign(this, Polyline.ownDefaults);\n this.setOptions(options);\n this.points = points;\n const { left, top } = options;\n this.initialized = true;\n this.setBoundingBox(true);\n typeof left === 'number' && this.set(LEFT, left);\n typeof top === 'number' && this.set(TOP, top);\n }\n\n protected isOpen() {\n return true;\n }\n\n private _projectStrokeOnPoints(options: TProjectStrokeOnPointsOptions) {\n return projectStrokeOnPoints(this.points, options, this.isOpen());\n }\n\n /**\n * Calculate the polygon bounding box\n * @private\n */\n _calcDimensions(options?: Partial) {\n options = {\n scaleX: this.scaleX,\n scaleY: this.scaleY,\n skewX: this.skewX,\n skewY: this.skewY,\n strokeLineCap: this.strokeLineCap,\n strokeLineJoin: this.strokeLineJoin,\n strokeMiterLimit: this.strokeMiterLimit,\n strokeUniform: this.strokeUniform,\n strokeWidth: this.strokeWidth,\n ...(options || {}),\n };\n const points = this.exactBoundingBox\n ? this._projectStrokeOnPoints(\n options as TProjectStrokeOnPointsOptions,\n ).map((projection) => projection.projectedPoint)\n : this.points;\n if (points.length === 0) {\n return {\n left: 0,\n top: 0,\n width: 0,\n height: 0,\n pathOffset: new Point(),\n strokeOffset: new Point(),\n strokeDiff: new Point(),\n };\n }\n const bbox = makeBoundingBoxFromPoints(points),\n // Remove scale effect, since it's applied after\n matrix = calcDimensionsMatrix({ ...options, scaleX: 1, scaleY: 1 }),\n bboxNoStroke = makeBoundingBoxFromPoints(\n this.points.map((p) => transformPoint(p, matrix, true)),\n ),\n scale = new Point(this.scaleX, this.scaleY);\n let offsetX = bbox.left + bbox.width / 2,\n offsetY = bbox.top + bbox.height / 2;\n if (this.exactBoundingBox) {\n offsetX = offsetX - offsetY * Math.tan(degreesToRadians(this.skewX));\n // Order of those assignments is important.\n // offsetY relies on offsetX being already changed by the line above\n offsetY = offsetY - offsetX * Math.tan(degreesToRadians(this.skewY));\n }\n\n return {\n ...bbox,\n pathOffset: new Point(offsetX, offsetY),\n strokeOffset: new Point(bboxNoStroke.left, bboxNoStroke.top)\n .subtract(new Point(bbox.left, bbox.top))\n .multiply(scale),\n strokeDiff: new Point(bbox.width, bbox.height)\n .subtract(new Point(bboxNoStroke.width, bboxNoStroke.height))\n .multiply(scale),\n };\n }\n\n /**\n * This function is an helper for svg import. it returns the center of the object in the svg\n * untransformed coordinates, by look at the polyline/polygon points.\n * @private\n * @return {Point} center point from element coordinates\n */\n _findCenterFromElement(): Point {\n const bbox = makeBoundingBoxFromPoints(this.points);\n return new Point(bbox.left + bbox.width / 2, bbox.top + bbox.height / 2);\n }\n\n setDimensions() {\n this.setBoundingBox();\n }\n\n setBoundingBox(adjustPosition?: boolean) {\n const { left, top, width, height, pathOffset, strokeOffset, strokeDiff } =\n this._calcDimensions();\n this.set({ width, height, pathOffset, strokeOffset, strokeDiff });\n adjustPosition &&\n this.setPositionByOrigin(\n new Point(left + width / 2, top + height / 2),\n CENTER,\n CENTER,\n );\n }\n\n /**\n * @deprecated intermidiate method to be removed, do not use\n */\n protected isStrokeAccountedForInDimensions() {\n return this.exactBoundingBox;\n }\n\n /**\n * @override stroke is taken in account in size\n */\n _getNonTransformedDimensions() {\n return this.exactBoundingBox\n ? // TODO: fix this\n new Point(this.width, this.height)\n : super._getNonTransformedDimensions();\n }\n\n /**\n * @override stroke and skewing are taken into account when projecting stroke on points,\n * therefore we don't want the default calculation to account for skewing as well.\n * Though it is possible to pass `width` and `height` in `options`, doing so is very strange, use with discretion.\n *\n * @private\n */\n _getTransformedDimensions(options: any = {}) {\n if (this.exactBoundingBox) {\n let size: Point;\n /* When `strokeUniform = true`, any changes to the properties require recalculating the `width` and `height` because\n the stroke projections are affected.\n When `strokeUniform = false`, we don't need to recalculate for scale transformations, as the effect of scale on\n projections follows a linear function (e.g. scaleX of 2 just multiply width by 2)*/\n if (\n Object.keys(options).some(\n (key) =>\n this.strokeUniform ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof TProjectStrokeOnPointsOptions,\n ),\n )\n ) {\n const { width, height } = this._calcDimensions(options);\n size = new Point(options.width ?? width, options.height ?? height);\n } else {\n size = new Point(\n options.width ?? this.width,\n options.height ?? this.height,\n );\n }\n return size.multiply(\n new Point(options.scaleX || this.scaleX, options.scaleY || this.scaleY),\n );\n } else {\n return super._getTransformedDimensions(options);\n }\n }\n\n /**\n * Recalculates dimensions when changing skew and scale\n * @private\n */\n _set(key: string, value: any) {\n const changed = this.initialized && this[key as keyof this] !== value;\n const output = super._set(key, value);\n if (\n this.exactBoundingBox &&\n changed &&\n (((key === SCALE_X || key === SCALE_Y) &&\n this.strokeUniform &&\n (this.constructor as typeof Polyline).layoutProperties.includes(\n 'strokeUniform',\n )) ||\n (this.constructor as typeof Polyline).layoutProperties.includes(\n key as keyof Polyline,\n ))\n ) {\n this.setDimensions();\n }\n return output;\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject(propertiesToInclude),\n points: this.points.map(({ x, y }) => ({ x, y })),\n };\n }\n\n /**\n * Returns svg representation of an instance\n * @return {Array} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const points = [],\n diffX = this.pathOffset.x,\n diffY = this.pathOffset.y,\n NUM_FRACTION_DIGITS = config.NUM_FRACTION_DIGITS;\n\n for (let i = 0, len = this.points.length; i < len; i++) {\n points.push(\n toFixed(this.points[i].x - diffX, NUM_FRACTION_DIGITS),\n ',',\n toFixed(this.points[i].y - diffY, NUM_FRACTION_DIGITS),\n ' ',\n );\n }\n return [\n `<${\n (this.constructor as typeof Polyline).type.toLowerCase() as\n | 'polyline'\n | 'polygon'\n } `,\n 'COMMON_PARTS',\n `points=\"${points.join('')}\" />\\n`,\n ];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const len = this.points.length,\n x = this.pathOffset.x,\n y = this.pathOffset.y;\n\n if (!len || isNaN(this.points[len - 1].y)) {\n // do not draw if no points or odd points\n // NaN comes from parseFloat of a empty string in parser\n return;\n }\n ctx.beginPath();\n ctx.moveTo(this.points[0].x - x, this.points[0].y - y);\n for (let i = 0; i < len; i++) {\n const point = this.points[i];\n ctx.lineTo(point.x - x, point.y - y);\n }\n !this.isOpen() && ctx.closePath();\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity of this instance\n */\n complexity(): number {\n return this.points.length;\n }\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link Polyline.fromElement})\n * @static\n * @memberOf Polyline\n * @see: http://www.w3.org/TR/SVG/shapes.html#PolylineElement\n */\n static ATTRIBUTE_NAMES = [...SHARED_ATTRIBUTES];\n\n /**\n * Returns Polyline instance from an SVG element\n * @static\n * @memberOf Polyline\n * @param {HTMLElement} element Element to parser\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const points = parsePointsAttribute(element.getAttribute('points')),\n // we omit left and top to instruct the constructor to position the object using the bbox\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n { left, top, ...parsedAttributes } = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return new this(points, {\n ...parsedAttributes,\n ...options,\n });\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns Polyline instance from an object representation\n * @static\n * @memberOf Polyline\n * @param {Object} object Object to create an instance from\n * @returns {Promise}\n */\n static fromObject>(object: T) {\n return this._fromObject(object, {\n extraParam: 'points',\n });\n }\n}\n\nclassRegistry.setClass(Polyline);\nclassRegistry.setSVGClass(Polyline);\n","import { classRegistry } from '../ClassRegistry';\nimport { Polyline, polylineDefaultValues } from './Polyline';\n\nexport class Polygon extends Polyline {\n static ownDefaults = polylineDefaultValues;\n\n static type = 'Polygon';\n\n protected isOpen() {\n return false;\n }\n}\n\nclassRegistry.setClass(Polygon);\nclassRegistry.setSVGClass(Polygon);\n","import { FILL, LEFT, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough';\n\nexport const styleProperties: Readonly = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: 'normal',\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: 'normal',\n lineHeight: 1.16,\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.315,\n overline: -0.88,\n },\n _fontSizeMult: 1.13,\n charSpacing: 0,\n deltaY: 0,\n direction: 'ltr',\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n","import type { ObjectEvents } from '../../EventTypeDefs';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { TOptions } from '../../typedefs';\nimport { FabricObject } from '../Object/FabricObject';\nimport { styleProperties } from './constants';\nimport type { StylePropertiesType } from './constants';\nimport type { FabricText } from './Text';\nimport { pick } from '../../util';\nimport { pickBy } from '../../util/misc/pick';\n\nexport type CompleteTextStyleDeclaration = Pick<\n FabricText,\n StylePropertiesType\n>;\n\nexport type TextStyleDeclaration = Partial;\n\nexport type TextStyle = {\n [line: number | string]: { [char: number | string]: TextStyleDeclaration };\n};\n\nexport abstract class StyledText<\n Props extends TOptions = Partial,\n SProps extends SerializedObjectProps = SerializedObjectProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n> extends FabricObject {\n declare abstract styles: TextStyle;\n protected declare abstract _textLines: string[][];\n protected declare _forceClearCache: boolean;\n static _styleProperties: Readonly = styleProperties;\n abstract get2DCursorLocation(\n selectionStart: number,\n skipWrapping?: boolean,\n ): { charIndex: number; lineIndex: number };\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex?: number): boolean {\n if (!this.styles) {\n return true;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return true;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * Returns true if object has a style property or has it ina specified line\n * This function is used to detect if a text will use a particular property or not.\n * @param {String} property to check for\n * @param {Number} lineIndex to check the style on\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex?: number): boolean {\n if (!this.styles) {\n return false;\n }\n if (typeof lineIndex !== 'undefined' && !this.styles[lineIndex]) {\n return false;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { 0: this.styles[lineIndex] };\n // eslint-disable-next-line\n for (const p1 in obj) {\n // eslint-disable-next-line\n for (const p2 in obj[p1]) {\n if (typeof obj[p1][p2][property] !== 'undefined') {\n return true;\n }\n }\n }\n return false;\n }\n\n /**\n * Check if characters in a text have a value for a property\n * whose value matches the textbox's value for that property. If so,\n * the character-level property is deleted. If the character\n * has no other properties, then it is also deleted. Finally,\n * if the line containing that character has no other characters\n * then it also is deleted.\n */\n cleanStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return false;\n }\n const obj = this.styles;\n let stylesCount = 0,\n letterCount,\n stylePropertyValue,\n allStyleObjectPropertiesMatch = true,\n graphemeCount = 0;\n for (const p1 in obj) {\n letterCount = 0;\n for (const p2 in obj[p1]) {\n const styleObject = obj[p1][p2] || {},\n stylePropertyHasBeenSet = styleObject[property] !== undefined;\n\n stylesCount++;\n\n if (stylePropertyHasBeenSet) {\n if (!stylePropertyValue) {\n stylePropertyValue = styleObject[property];\n } else if (styleObject[property] !== stylePropertyValue) {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (styleObject[property] === this[property as keyof this]) {\n delete styleObject[property];\n }\n } else {\n allStyleObjectPropertiesMatch = false;\n }\n\n if (Object.keys(styleObject).length !== 0) {\n letterCount++;\n } else {\n delete obj[p1][p2];\n }\n }\n\n if (letterCount === 0) {\n delete obj[p1];\n }\n }\n // if every grapheme has the same style set then\n // delete those styles and set it on the parent\n for (let i = 0; i < this._textLines.length; i++) {\n graphemeCount += this._textLines[i].length;\n }\n if (allStyleObjectPropertiesMatch && stylesCount === graphemeCount) {\n this[property as keyof this] = stylePropertyValue as any;\n this.removeStyle(property);\n }\n }\n\n /**\n * Remove a style property or properties from all individual character styles\n * in a text object. Deletes the character style object if it contains no other style\n * props. Deletes a line style object if it contains no other character styles.\n *\n * @param {String} props The property to remove from character styles.\n */\n removeStyle(property: keyof TextStyleDeclaration) {\n if (!this.styles) {\n return;\n }\n const obj = this.styles;\n let line, lineNum, charNum;\n for (lineNum in obj) {\n line = obj[lineNum];\n for (charNum in line) {\n delete line[charNum][property];\n if (Object.keys(line[charNum]).length === 0) {\n delete line[charNum];\n }\n }\n if (Object.keys(line).length === 0) {\n delete obj[lineNum];\n }\n }\n }\n\n private _extendStyles(index: number, style: TextStyleDeclaration): void {\n const { lineIndex, charIndex } = this.get2DCursorLocation(index);\n\n if (!this._getLineStyle(lineIndex)) {\n this._setLineStyle(lineIndex);\n }\n\n const newStyle = pickBy(\n {\n // first create a new object that is a merge of existing and new\n ...this._getStyleDeclaration(lineIndex, charIndex),\n ...style,\n // use the predicate to discard undefined values\n },\n (value) => value !== undefined,\n );\n\n // finally assign to the old position the new style\n this._setStyleDeclaration(lineIndex, charIndex, newStyle);\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number,\n endIndex?: number,\n complete?: boolean,\n ): TextStyleDeclaration[] {\n const styles: TextStyleDeclaration[] = [];\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n styles.push(this.getStyleAtPosition(i, complete));\n }\n return styles;\n }\n\n /**\n * Gets style of a current selection/cursor position\n * @param {Number} position to get styles at\n * @param {Boolean} [complete] full style if true\n * @return {Object} style Style object at a specified index\n * @private\n */\n getStyleAtPosition(position: number, complete?: boolean) {\n const { lineIndex, charIndex } = this.get2DCursorLocation(position);\n return complete\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex)\n : this._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} styles Styles object\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified startIndex + 1\n */\n setSelectionStyles(styles: object, startIndex: number, endIndex?: number) {\n for (let i = startIndex; i < (endIndex || startIndex); i++) {\n this._extendStyles(i, styles);\n }\n /* not included in _extendStyles to avoid clearing cache more than once */\n this._forceClearCache = true;\n }\n\n /**\n * Get a reference, not a clone, to the style object for a given character,\n * if no style is set for a line or char, return a new empty object.\n * This is tricky and confusing because when you get an empty object you can't\n * determine if it is a reference or a new one.\n * @TODO this should always return a reference or always a clone or undefined when necessary.\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n const lineStyle = this.styles && this.styles[lineIndex];\n return lineStyle ? lineStyle[charIndex] ?? {} : {};\n }\n\n /**\n * return a new object that contains all the style property for a character\n * the object returned is newly created\n * @param {Number} lineIndex of the line where the character is\n * @param {Number} charIndex position of the character on the line\n * @return {Object} style object\n */\n getCompleteStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): CompleteTextStyleDeclaration {\n return {\n ...pick(\n this,\n (this.constructor as typeof StyledText)\n ._styleProperties as (keyof this)[],\n ),\n ...this._getStyleDeclaration(lineIndex, charIndex),\n } as CompleteTextStyleDeclaration;\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n this.styles[lineIndex][charIndex] = style;\n }\n\n /**\n *\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n delete this.styles[lineIndex][charIndex];\n }\n\n /**\n * @param {Number} lineIndex\n * @return {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n return !!this.styles[lineIndex];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n this.styles[lineIndex] = {};\n }\n\n protected _deleteLineStyle(lineIndex: number) {\n delete this.styles[lineIndex];\n }\n}\n","import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText } from './Text';\nimport { STROKE, FILL } from '../../constants';\n\nconst multipleSpacesRegex = / +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n color: string,\n left: number,\n top: number,\n width: number,\n height: number,\n) {\n return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n const offsets = this._getSVGLeftTopOffsets(),\n textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n return this._wrapSVGTextAndBg(textAndBg);\n }\n\n toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n return this._createBaseSVGMarkup(this._toSVG(), {\n reviver,\n noStyle: true,\n withShadow: true,\n });\n }\n\n private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n return {\n textLeft: -this.width / 2,\n textTop: -this.height / 2,\n lineTop: this.getHeightOfLine(0),\n };\n }\n\n private _wrapSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n {\n textBgRects,\n textSpans,\n }: {\n textSpans: string[];\n textBgRects: string[];\n },\n ) {\n const noShadow = true,\n textDecoration = this.getSvgTextDecoration(this);\n return [\n textBgRects.join(''),\n '\\t\\t',\n textSpans.join(''),\n '\\n',\n ];\n }\n\n /**\n * @private\n * @param {Number} textTopOffset Text top offset\n * @param {Number} textLeftOffset Text left offset\n * @return {Object}\n */\n private _getSVGTextAndBg(\n this: TextSVGExportMixin & FabricText,\n textTopOffset: number,\n textLeftOffset: number,\n ) {\n const textSpans: string[] = [],\n textBgRects: string[] = [];\n let height = textTopOffset,\n lineOffset;\n\n // bounding-box background\n this.backgroundColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n this.backgroundColor,\n -this.width / 2,\n -this.height / 2,\n this.width,\n this.height,\n ),\n );\n\n // text and text-background\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineOffset = this._getLineLeftOffset(i);\n if (this.direction === 'rtl') {\n lineOffset += this.width;\n }\n if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n this._setSVGTextLineBg(\n textBgRects,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n }\n this._setSVGTextLineText(\n textSpans,\n i,\n textLeftOffset + lineOffset,\n height,\n );\n height += this.getHeightOfLine(i);\n }\n\n return {\n textSpans,\n textBgRects,\n };\n }\n\n private _createTextCharSpan(\n this: TextSVGExportMixin & FabricText,\n char: string,\n styleDecl: TextStyleDeclaration,\n left: number,\n top: number,\n ) {\n const styleProps = this.getSvgSpanStyles(\n styleDecl,\n char !== char.trim() || !!char.match(multipleSpacesRegex),\n ),\n fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n dy = styleDecl.deltaY,\n dySpan = dy ? ` dy=\"${toFixed(dy, config.NUM_FRACTION_DIGITS)}\" ` : '';\n\n return `${escapeXml(char)}`;\n }\n\n private _setSVGTextLineText(\n this: TextSVGExportMixin & FabricText,\n textSpans: string[],\n lineIndex: number,\n textLeftOffset: number,\n textTopOffset: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n line = this._textLines[lineIndex];\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n style,\n boxWidth = 0,\n timeToRender;\n\n textTopOffset +=\n (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i];\n if (boxWidth === 0) {\n textLeftOffset += charBox.kernedWidth - charBox.width;\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, true);\n }\n if (timeToRender) {\n style = this._getStyleDeclaration(lineIndex, i);\n textSpans.push(\n this._createTextCharSpan(\n charsToRender,\n style,\n textLeftOffset,\n textTopOffset,\n ),\n );\n charsToRender = '';\n actualStyle = nextStyle;\n if (this.direction === 'rtl') {\n textLeftOffset -= boxWidth;\n } else {\n textLeftOffset += boxWidth;\n }\n boxWidth = 0;\n }\n }\n }\n\n private _setSVGTextLineBg(\n this: TextSVGExportMixin & FabricText,\n textBgRects: (string | number)[],\n i: number,\n leftOffset: number,\n textTopOffset: number,\n ) {\n const line = this._textLines[i],\n heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n let boxWidth = 0,\n boxStart = 0,\n currentColor,\n lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < line.length; j++) {\n const { left, width, kernedWidth } = this.__charBounds[i][j];\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (currentColor !== lastColor) {\n lastColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n boxStart = left;\n boxWidth = width;\n lastColor = currentColor;\n } else {\n boxWidth += kernedWidth;\n }\n }\n currentColor &&\n textBgRects.push(\n ...createSVGInlineRect(\n lastColor,\n leftOffset + boxStart,\n textTopOffset,\n boxWidth,\n heightOfLine,\n ),\n );\n }\n\n /**\n * @deprecated unused\n */\n _getSVGLineTopOffset(\n this: TextSVGExportMixin & FabricText,\n lineIndex: number,\n ) {\n let lineTopOffset = 0,\n j;\n for (j = 0; j < lineIndex; j++) {\n lineTopOffset += this.getHeightOfLine(j);\n }\n const lastHeight = this.getHeightOfLine(j);\n return {\n lineTop: lineTopOffset,\n offset:\n ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n (this.lineHeight * this._fontSizeMult),\n };\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Boolean} skipShadow a boolean to skip shadow filter output\n * @return {String}\n */\n getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n return `${super.getSvgStyles(skipShadow)} white-space: pre;`;\n }\n\n /**\n * Returns styles-string for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n * @return {String}\n */\n getSvgSpanStyles(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n useWhiteSpace?: boolean,\n ) {\n const {\n fontFamily,\n strokeWidth,\n stroke,\n fill,\n fontSize,\n fontStyle,\n fontWeight,\n deltaY,\n } = style;\n\n const textDecoration = this.getSvgTextDecoration(style);\n\n return [\n stroke ? colorPropToSVG(STROKE, stroke) : '',\n strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n fontFamily\n ? `font-family: ${\n !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n ? `'${fontFamily}'`\n : fontFamily\n }; `\n : '',\n fontSize ? `font-size: ${fontSize}px; ` : '',\n fontStyle ? `font-style: ${fontStyle}; ` : '',\n fontWeight ? `font-weight: ${fontWeight}; ` : '',\n textDecoration ? `text-decoration: ${textDecoration}; ` : textDecoration,\n fill ? colorPropToSVG(FILL, fill) : '',\n deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n useWhiteSpace ? 'white-space: pre; ' : '',\n ].join('');\n }\n\n /**\n * Returns text-decoration property for svg-export\n * @param {Object} style the object from which to retrieve style properties\n * @return {String}\n */\n getSvgTextDecoration(\n this: TextSVGExportMixin & FabricText,\n style: TextStyleDeclaration,\n ) {\n return (['overline', 'underline', 'line-through'] as const)\n .filter(\n (decoration) =>\n style[\n decoration.replace('-', '') as\n | 'overline'\n | 'underline'\n | 'linethrough'\n ],\n )\n .join(' ');\n }\n}\n","import { cache } from '../../cache';\nimport { DEFAULT_SVG_FONT_SIZE, FILL, STROKE } from '../../constants';\nimport type { ObjectEvents } from '../../EventTypeDefs';\nimport type {\n CompleteTextStyleDeclaration,\n TextStyle,\n TextStyleDeclaration,\n} from './StyledText';\nimport { StyledText } from './StyledText';\nimport { SHARED_ATTRIBUTES } from '../../parser/attributes';\nimport { parseAttributes } from '../../parser/parseAttributes';\nimport type {\n Abortable,\n TCacheCanvasDimensions,\n TClassProperties,\n TFiller,\n TOptions,\n} from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport { graphemeSplit } from '../../util/lang_string';\nimport { createCanvasElementFor } from '../../util/misc/dom';\nimport type { TextStyleArray } from '../../util/misc/textStyles';\nimport {\n hasStyleChanged,\n stylesFromArray,\n stylesToArray,\n} from '../../util/misc/textStyles';\nimport { getPathSegmentsInfo, getPointOnPath } from '../../util/path';\nimport { cacheProperties } from '../Object/FabricObject';\nimport type { Path } from '../Path';\nimport { TextSVGExportMixin } from './TextSVGExportMixin';\nimport { applyMixins } from '../../util/applyMixins';\nimport type { FabricObjectProps, SerializedObjectProps } from '../Object/types';\nimport type { StylePropertiesType } from './constants';\nimport {\n additionalProps,\n textDefaultValues,\n textLayoutProperties,\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from './constants';\nimport { CENTER, LEFT, RIGHT, TOP, BOTTOM } from '../../constants';\nimport { isFiller } from '../../util/typeAssertions';\nimport type { Gradient } from '../../gradient/Gradient';\nimport type { Pattern } from '../../Pattern';\nimport type { CSSRules } from '../../parser/typedefs';\n\nlet measuringContext: CanvasRenderingContext2D | null;\n\n/**\n * Return a context for measurement of text string.\n * if created it gets stored for reuse\n */\nfunction getMeasuringContext() {\n if (!measuringContext) {\n const canvas = createCanvasElementFor({\n width: 0,\n height: 0,\n });\n measuringContext = canvas.getContext('2d');\n }\n return measuringContext;\n}\n\nexport type TPathSide = 'left' | 'right';\n\nexport type TPathAlign = 'baseline' | 'center' | 'ascender' | 'descender';\n\nexport type TextLinesInfo = {\n lines: string[];\n graphemeLines: string[][];\n graphemeText: string[];\n _unwrappedLines: string[][];\n};\n\n/**\n * Measure and return the info of a single grapheme.\n * needs the the info of previous graphemes already filled\n * Override to customize measuring\n */\nexport type GraphemeBBox = {\n width: number;\n height: number;\n kernedWidth: number;\n left: number;\n deltaY: number;\n renderLeft?: number;\n renderTop?: number;\n angle?: number;\n};\n\n// @TODO this is not complete\ninterface UniqueTextProps {\n charSpacing: number;\n lineHeight: number;\n fontSize: number;\n fontWeight: string | number;\n fontFamily: string;\n fontStyle: string;\n pathSide: TPathSide;\n pathAlign: TPathAlign;\n underline: boolean;\n overline: boolean;\n linethrough: boolean;\n textAlign: string;\n direction: CanvasDirection;\n path?: Path;\n}\n\nexport interface SerializedTextProps\n extends SerializedObjectProps,\n UniqueTextProps {\n styles: TextStyleArray | TextStyle;\n}\n\nexport interface TextProps extends FabricObjectProps, UniqueTextProps {\n styles: TextStyle;\n}\n\n/**\n * Text class\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-2#text}\n */\nexport class FabricText<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends StyledText\n implements UniqueTextProps\n{\n /**\n * Properties that requires a text layout recalculation when changed\n * @type string[]\n * @protected\n */\n static textLayoutProperties: string[] = textLayoutProperties;\n\n /**\n * @private\n */\n declare _reNewline: RegExp;\n\n /**\n * Use this regular expression to filter for whitespaces that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpacesAndTabs: RegExp;\n\n /**\n * Use this regular expression to filter for whitespace that is not a new line.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reSpaceAndTab: RegExp;\n\n /**\n * Use this regular expression to filter consecutive groups of non spaces.\n * Mostly used when text is 'justify' aligned.\n * @private\n */\n declare _reWords: RegExp;\n\n declare text: string;\n\n /**\n * Font size (in pixels)\n * @type Number\n * @default\n */\n declare fontSize: number;\n\n /**\n * Font weight (e.g. bold, normal, 400, 600, 800)\n * @type {(Number|String)}\n * @default\n */\n declare fontWeight: string | number;\n\n /**\n * Font family\n * @type String\n * @default\n */\n declare fontFamily: string;\n\n /**\n * Text decoration underline.\n * @type Boolean\n * @default\n */\n declare underline: boolean;\n\n /**\n * Text decoration overline.\n * @type Boolean\n * @default\n */\n declare overline: boolean;\n\n /**\n * Text decoration linethrough.\n * @type Boolean\n * @default\n */\n declare linethrough: boolean;\n\n /**\n * Text alignment. Possible values: \"left\", \"center\", \"right\", \"justify\",\n * \"justify-left\", \"justify-center\" or \"justify-right\".\n * @type String\n * @default\n */\n declare textAlign: string;\n\n /**\n * Font style . Possible values: \"\", \"normal\", \"italic\" or \"oblique\".\n * @type String\n * @default\n */\n declare fontStyle: string;\n\n /**\n * Line height\n * @type Number\n * @default\n */\n declare lineHeight: number;\n\n /**\n * Superscript schema object (minimum overlap)\n */\n declare superscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (upwards)\n * @default -0.35\n */\n baseline: number;\n };\n\n /**\n * Subscript schema object (minimum overlap)\n */\n declare subscript: {\n /**\n * fontSize factor\n * @default 0.6\n */\n size: number;\n /**\n * baseline-shift factor (downwards)\n * @default 0.11\n */\n baseline: number;\n };\n\n /**\n * Background color of text lines\n * @type String\n * @default\n */\n declare textBackgroundColor: string;\n\n declare styles: TextStyle;\n\n /**\n * Path that the text should follow.\n * since 4.6.0 the path will be drawn automatically.\n * if you want to make the path visible, give it a stroke and strokeWidth or fill value\n * if you want it to be hidden, assign visible = false to the path.\n * This feature is in BETA, and SVG import/export is not yet supported.\n * @type Path\n * @example\n * const textPath = new Text('Text on a path', {\n * top: 150,\n * left: 150,\n * textAlign: 'center',\n * charSpacing: -50,\n * path: new Path('M 0 0 C 50 -100 150 -100 200 0', {\n * strokeWidth: 1,\n * visible: false\n * }),\n * pathSide: 'left',\n * pathStartOffset: 0\n * });\n * @default\n */\n declare path?: Path;\n\n /**\n * Offset amount for text path starting position\n * Only used when text has a path\n * @type Number\n * @default\n */\n declare pathStartOffset: number;\n\n /**\n * Which side of the path the text should be drawn on.\n * Only used when text has a path\n * @type {TPathSide} 'left|right'\n * @default\n */\n declare pathSide: TPathSide;\n\n /**\n * How text is aligned to the path. This property determines\n * the perpendicular position of each character relative to the path.\n * (one of \"baseline\", \"center\", \"ascender\", \"descender\")\n * This feature is in BETA, and its behavior may change\n * @type TPathAlign\n * @default\n */\n declare pathAlign: TPathAlign;\n\n /**\n * @private\n */\n declare _fontSizeFraction: number;\n\n /**\n * @private\n */\n declare offsets: { underline: number; linethrough: number; overline: number };\n\n /**\n * Text Line proportion to font Size (in pixels)\n * @type Number\n * @default\n */\n declare _fontSizeMult: number;\n\n /**\n * additional space between characters\n * expressed in thousands of em unit\n * @type Number\n * @default\n */\n declare charSpacing: number;\n\n /**\n * Baseline shift, styles only, keep at 0 for the main text object\n * @type {Number}\n * @default\n */\n declare deltaY: number;\n\n /**\n * WARNING: EXPERIMENTAL. NOT SUPPORTED YET\n * determine the direction of the text.\n * This has to be set manually together with textAlign and originX for proper\n * experience.\n * some interesting link for the future\n * https://www.w3.org/International/questions/qa-bidi-unicode-controls\n * @since 4.5.0\n * @type {CanvasDirection} 'ltr|rtl'\n * @default\n */\n declare direction: CanvasDirection;\n\n /**\n * contains characters bounding boxes\n * This variable is considered to be protected.\n * But for how mixins are implemented right now, we can't leave it private\n * @protected\n */\n __charBounds: GraphemeBBox[][] = [];\n\n /**\n * use this size when measuring text. To avoid IE11 rounding errors\n * @type {Number}\n * @default\n * @readonly\n * @private\n */\n declare CACHE_FONT_SIZE: number;\n\n /**\n * contains the min text width to avoid getting 0\n * @type {Number}\n * @default\n */\n declare MIN_TEXT_WIDTH: number;\n\n /**\n * contains the the text of the object, divided in lines as they are displayed\n * on screen. Wrapping will divide the text independently of line breaks\n * @type {string[]}\n * @default\n */\n declare textLines: string[];\n\n /**\n * same as textlines, but each line is an array of graphemes as split by splitByGrapheme\n * @type {string[]}\n * @default\n */\n declare _textLines: string[][];\n\n declare _unwrappedTextLines: string[][];\n declare _text: string[];\n declare cursorWidth: number;\n declare __lineHeights: number[];\n declare __lineWidths: number[];\n declare initialized?: true;\n\n static cacheProperties = [...cacheProperties, ...additionalProps];\n\n static ownDefaults = textDefaultValues;\n\n static type = 'Text';\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...FabricText.ownDefaults };\n }\n\n constructor(text: string, options?: Props) {\n super();\n Object.assign(this, FabricText.ownDefaults);\n this.setOptions(options);\n if (!this.styles) {\n this.styles = {};\n }\n this.text = text;\n this.initialized = true;\n if (this.path) {\n this.setPathInfo();\n }\n this.initDimensions();\n this.setCoords();\n }\n\n /**\n * If text has a path, it will add the extra information needed\n * for path and text calculations\n */\n setPathInfo() {\n const path = this.path;\n if (path) {\n path.segmentsInfo = getPathSegmentsInfo(path.path);\n }\n }\n\n /**\n * @private\n * Divides text into lines of text and lines of graphemes.\n */\n _splitText(): TextLinesInfo {\n const newLines = this._splitTextIntoLines(this.text);\n this.textLines = newLines.lines;\n this._textLines = newLines.graphemeLines;\n this._unwrappedTextLines = newLines._unwrappedLines;\n this._text = newLines.graphemeText;\n return newLines;\n }\n\n /**\n * Initialize or update text dimensions.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n */\n initDimensions() {\n this._splitText();\n this._clearCache();\n this.dirty = true;\n if (this.path) {\n this.width = this.path.width;\n this.height = this.path.height;\n } else {\n this.width =\n this.calcTextWidth() || this.cursorWidth || this.MIN_TEXT_WIDTH;\n this.height = this.calcTextHeight();\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n }\n\n /**\n * Enlarge space boxes and shift the others\n */\n enlargeSpaces() {\n let diffSpace,\n currentLineWidth,\n numberOfSpaces,\n accumulatedSpace,\n line,\n charBound,\n spaces;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n if (\n this.textAlign !== JUSTIFY &&\n (i === len - 1 || this.isEndOfWrapping(i))\n ) {\n continue;\n }\n accumulatedSpace = 0;\n line = this._textLines[i];\n currentLineWidth = this.getLineWidth(i);\n if (\n currentLineWidth < this.width &&\n (spaces = this.textLines[i].match(this._reSpacesAndTabs))\n ) {\n numberOfSpaces = spaces.length;\n diffSpace = (this.width - currentLineWidth) / numberOfSpaces;\n for (let j = 0; j <= line.length; j++) {\n charBound = this.__charBounds[i][j];\n if (this._reSpaceAndTab.test(line[j])) {\n charBound.width += diffSpace;\n charBound.kernedWidth += diffSpace;\n charBound.left += accumulatedSpace;\n accumulatedSpace += diffSpace;\n } else {\n charBound.left += accumulatedSpace;\n }\n }\n }\n }\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n return lineIndex === this._textLines.length - 1;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * It return always 1 for text and Itext. Textbox has its own implementation\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1;\n missingNewlineOffset(_lineIndex: number): 1 {\n return 1;\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor\n * @param {Number} selectionStart\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(selectionStart: number, skipWrapping?: boolean) {\n const lines = skipWrapping ? this._unwrappedTextLines : this._textLines;\n let i: number;\n for (i = 0; i < lines.length; i++) {\n if (selectionStart <= lines[i].length) {\n return {\n lineIndex: i,\n charIndex: selectionStart,\n };\n }\n selectionStart -=\n lines[i].length + this.missingNewlineOffset(i, skipWrapping);\n }\n return {\n lineIndex: i - 1,\n charIndex:\n lines[i - 1].length < selectionStart\n ? lines[i - 1].length\n : selectionStart,\n };\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of text object\n */\n toString(): string {\n return `#`;\n }\n\n /**\n * Return the dimension and the zoom level needed to create a cache canvas\n * big enough to host the object to be cached.\n * @private\n * @param {Object} dim.x width of object to be cached\n * @param {Object} dim.y height of object to be cached\n * @return {Object}.width width of canvas\n * @return {Object}.height height of canvas\n * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache\n * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache\n */\n _getCacheCanvasDimensions(): TCacheCanvasDimensions {\n const dims = super._getCacheCanvasDimensions();\n const fontSize = this.fontSize;\n dims.width += fontSize * dims.zoomX;\n dims.height += fontSize * dims.zoomY;\n return dims;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n const path = this.path;\n path && !path.isNotVisible() && path._render(ctx);\n this._setTextStyles(ctx);\n this._renderTextLinesBackground(ctx);\n this._renderTextDecoration(ctx, 'underline');\n this._renderText(ctx);\n this._renderTextDecoration(ctx, 'overline');\n this._renderTextDecoration(ctx, 'linethrough');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderText(ctx: CanvasRenderingContext2D) {\n if (this.paintFirst === STROKE) {\n this._renderTextStroke(ctx);\n this._renderTextFill(ctx);\n } else {\n this._renderTextFill(ctx);\n this._renderTextStroke(ctx);\n }\n }\n\n /**\n * Set the font parameter of the context with the object properties or with charStyle\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [charStyle] object with font style properties\n * @param {String} [charStyle.fontFamily] Font Family\n * @param {Number} [charStyle.fontSize] Font size in pixels. ( without px suffix )\n * @param {String} [charStyle.fontWeight] Font weight\n * @param {String} [charStyle.fontStyle] Font style (italic|normal)\n */\n _setTextStyles(\n ctx: CanvasRenderingContext2D,\n charStyle?: any,\n forMeasuring?: boolean,\n ) {\n ctx.textBaseline = 'alphabetic';\n if (this.path) {\n switch (this.pathAlign) {\n case CENTER:\n ctx.textBaseline = 'middle';\n break;\n case 'ascender':\n ctx.textBaseline = TOP;\n break;\n case 'descender':\n ctx.textBaseline = BOTTOM;\n break;\n }\n }\n ctx.font = this._getFontDeclaration(charStyle, forMeasuring);\n }\n\n /**\n * calculate and return the text Width measuring each line.\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @return {Number} Maximum width of Text object\n */\n calcTextWidth(): number {\n let maxWidth = this.getLineWidth(0);\n\n for (let i = 1, len = this._textLines.length; i < len; i++) {\n const currentLineWidth = this.getLineWidth(i);\n if (currentLineWidth > maxWidth) {\n maxWidth = currentLineWidth;\n }\n }\n return maxWidth;\n }\n\n /**\n * @private\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} line Text to render\n * @param {Number} left Left position of text\n * @param {Number} top Top position of text\n * @param {Number} lineIndex Index of a line in a text\n */\n _renderTextLine(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: string[],\n left: number,\n top: number,\n lineIndex: number,\n ) {\n this._renderChars(method, ctx, line, left, top, lineIndex);\n }\n\n /**\n * Renders the text background for lines, taking care of style\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextLinesBackground(ctx: CanvasRenderingContext2D) {\n if (!this.textBackgroundColor && !this.styleHas('textBackgroundColor')) {\n return;\n }\n const originalFill = ctx.fillStyle,\n leftOffset = this._getLeftOffset();\n let lineTopOffset = this._getTopOffset();\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (\n !this.textBackgroundColor &&\n !this.styleHas('textBackgroundColor', i)\n ) {\n lineTopOffset += heightOfLine;\n continue;\n }\n const jlen = this._textLines[i].length;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxWidth = 0;\n let boxStart = 0;\n let drawStart;\n let currentColor;\n let lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n for (let j = 0; j < jlen; j++) {\n // at this point charbox are either standard or full with pathInfo if there is a path.\n const charBox = this.__charBounds[i][j] as Required;\n currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n if (this.path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillStyle = currentColor;\n currentColor &&\n ctx.fillRect(\n -charBox.width / 2,\n (-heightOfLine / this.lineHeight) * (1 - this._fontSizeFraction),\n charBox.width,\n heightOfLine / this.lineHeight,\n );\n ctx.restore();\n } else if (currentColor !== lastColor) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = lastColor;\n lastColor &&\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastColor = currentColor;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n if (currentColor && !this.path) {\n drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentColor;\n ctx.fillRect(\n drawStart,\n lineTopOffset,\n boxWidth,\n heightOfLine / this.lineHeight,\n );\n }\n lineTopOffset += heightOfLine;\n }\n ctx.fillStyle = originalFill;\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * measure and return the width of a single character.\n * possibly overridden to accommodate different measure logic or\n * to hook some external lib for character measurement\n * @private\n * @param {String} _char, char to be measured\n * @param {Object} charStyle style of char to be measured\n * @param {String} [previousChar] previous char\n * @param {Object} [prevCharStyle] style of previous char\n */\n _measureChar(\n _char: string,\n charStyle: CompleteTextStyleDeclaration,\n previousChar: string | undefined,\n prevCharStyle: CompleteTextStyleDeclaration | Record,\n ) {\n const fontCache = cache.getFontCache(charStyle),\n fontDeclaration = this._getFontDeclaration(charStyle),\n couple = previousChar + _char,\n stylesAreEqual =\n previousChar &&\n fontDeclaration === this._getFontDeclaration(prevCharStyle),\n fontMultiplier = charStyle.fontSize / this.CACHE_FONT_SIZE;\n let width: number | undefined,\n coupleWidth: number | undefined,\n previousWidth: number | undefined,\n kernedWidth: number | undefined;\n\n if (previousChar && fontCache[previousChar] !== undefined) {\n previousWidth = fontCache[previousChar];\n }\n if (fontCache[_char] !== undefined) {\n kernedWidth = width = fontCache[_char];\n }\n if (stylesAreEqual && fontCache[couple] !== undefined) {\n coupleWidth = fontCache[couple];\n kernedWidth = coupleWidth - previousWidth!;\n }\n if (\n width === undefined ||\n previousWidth === undefined ||\n coupleWidth === undefined\n ) {\n const ctx = getMeasuringContext()!;\n // send a TRUE to specify measuring font size CACHE_FONT_SIZE\n this._setTextStyles(ctx, charStyle, true);\n if (width === undefined) {\n kernedWidth = width = ctx.measureText(_char).width;\n fontCache[_char] = width;\n }\n if (previousWidth === undefined && stylesAreEqual && previousChar) {\n previousWidth = ctx.measureText(previousChar).width;\n fontCache[previousChar] = previousWidth;\n }\n if (stylesAreEqual && coupleWidth === undefined) {\n // we can measure the kerning couple and subtract the width of the previous character\n coupleWidth = ctx.measureText(couple).width;\n fontCache[couple] = coupleWidth;\n // safe to use the non-null since if undefined we defined it before.\n kernedWidth = coupleWidth - previousWidth!;\n }\n }\n return {\n width: width * fontMultiplier,\n kernedWidth: kernedWidth! * fontMultiplier,\n };\n }\n\n /**\n * Computes height of character at given position\n * @param {Number} line the line index number\n * @param {Number} _char the character index number\n * @return {Number} fontSize of the character\n */\n getHeightOfChar(line: number, _char: number): number {\n return this.getValueOfPropertyAt(line, _char, 'fontSize');\n }\n\n /**\n * measure a text line measuring all characters.\n * @param {Number} lineIndex line number\n */\n measureLine(lineIndex: number) {\n const lineInfo = this._measureLine(lineIndex);\n if (this.charSpacing !== 0) {\n lineInfo.width -= this._getWidthOfCharSpacing();\n }\n if (lineInfo.width < 0) {\n lineInfo.width = 0;\n }\n return lineInfo;\n }\n\n /**\n * measure every grapheme of a line, populating __charBounds\n * @param {Number} lineIndex\n * @return {Object} object.width total width of characters\n * @return {Object} object.numOfSpaces length of chars that match this._reSpacesAndTabs\n */\n _measureLine(lineIndex: number) {\n let width = 0,\n prevGrapheme: string | undefined,\n graphemeInfo: GraphemeBBox | undefined;\n\n const reverse = this.pathSide === RIGHT,\n path = this.path,\n line = this._textLines[lineIndex],\n llength = line.length,\n lineBounds = new Array(llength);\n\n this.__charBounds[lineIndex] = lineBounds;\n for (let i = 0; i < llength; i++) {\n const grapheme = line[i];\n graphemeInfo = this._getGraphemeBox(grapheme, lineIndex, i, prevGrapheme);\n lineBounds[i] = graphemeInfo;\n width += graphemeInfo.kernedWidth;\n prevGrapheme = grapheme;\n }\n // this latest bound box represent the last character of the line\n // to simplify cursor handling in interactive mode.\n lineBounds[llength] = {\n left: graphemeInfo ? graphemeInfo.left + graphemeInfo.width : 0,\n width: 0,\n kernedWidth: 0,\n height: this.fontSize,\n deltaY: 0,\n } as GraphemeBBox;\n if (path && path.segmentsInfo) {\n let positionInPath = 0;\n const totalPathLength =\n path.segmentsInfo[path.segmentsInfo.length - 1].length;\n switch (this.textAlign) {\n case LEFT:\n positionInPath = reverse ? totalPathLength - width : 0;\n break;\n case CENTER:\n positionInPath = (totalPathLength - width) / 2;\n break;\n case RIGHT:\n positionInPath = reverse ? 0 : totalPathLength - width;\n break;\n //todo - add support for justify\n }\n positionInPath += this.pathStartOffset * (reverse ? -1 : 1);\n for (\n let i = reverse ? llength - 1 : 0;\n reverse ? i >= 0 : i < llength;\n reverse ? i-- : i++\n ) {\n graphemeInfo = lineBounds[i];\n if (positionInPath > totalPathLength) {\n positionInPath %= totalPathLength;\n } else if (positionInPath < 0) {\n positionInPath += totalPathLength;\n }\n // it would probably much faster to send all the grapheme position for a line\n // and calculate path position/angle at once.\n this._setGraphemeOnPath(positionInPath, graphemeInfo);\n positionInPath += graphemeInfo.kernedWidth;\n }\n }\n return { width: width, numOfSpaces: 0 };\n }\n\n /**\n * Calculate the angle and the left,top position of the char that follow a path.\n * It appends it to graphemeInfo to be reused later at rendering\n * @private\n * @param {Number} positionInPath to be measured\n * @param {GraphemeBBox} graphemeInfo current grapheme box information\n * @param {Object} startingPoint position of the point\n */\n _setGraphemeOnPath(positionInPath: number, graphemeInfo: GraphemeBBox) {\n const centerPosition = positionInPath + graphemeInfo.kernedWidth / 2,\n path = this.path!;\n\n // we are at currentPositionOnPath. we want to know what point on the path is.\n const info = getPointOnPath(path.path, centerPosition, path.segmentsInfo)!;\n graphemeInfo.renderLeft = info.x - path.pathOffset.x;\n graphemeInfo.renderTop = info.y - path.pathOffset.y;\n graphemeInfo.angle = info.angle + (this.pathSide === RIGHT ? Math.PI : 0);\n }\n\n /**\n *\n * @param {String} grapheme to be measured\n * @param {Number} lineIndex index of the line where the char is\n * @param {Number} charIndex position in the line\n * @param {String} [prevGrapheme] character preceding the one to be measured\n * @returns {GraphemeBBox} grapheme bbox\n */\n _getGraphemeBox(\n grapheme: string,\n lineIndex: number,\n charIndex: number,\n prevGrapheme?: string,\n skipLeft?: boolean,\n ): GraphemeBBox {\n const style = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n prevStyle = prevGrapheme\n ? this.getCompleteStyleDeclaration(lineIndex, charIndex - 1)\n : {},\n info = this._measureChar(grapheme, style, prevGrapheme, prevStyle);\n let kernedWidth = info.kernedWidth,\n width = info.width,\n charSpacing;\n\n if (this.charSpacing !== 0) {\n charSpacing = this._getWidthOfCharSpacing();\n width += charSpacing;\n kernedWidth += charSpacing;\n }\n\n const box: GraphemeBBox = {\n width,\n left: 0,\n height: style.fontSize,\n kernedWidth,\n deltaY: style.deltaY,\n };\n if (charIndex > 0 && !skipLeft) {\n const previousBox = this.__charBounds[lineIndex][charIndex - 1];\n box.left =\n previousBox.left + previousBox.width + info.kernedWidth - info.width;\n }\n return box;\n }\n\n /**\n * Calculate height of line at 'lineIndex'\n * @param {Number} lineIndex index of line to calculate\n * @return {Number}\n */\n getHeightOfLine(lineIndex: number): number {\n if (this.__lineHeights[lineIndex]) {\n return this.__lineHeights[lineIndex];\n }\n\n // char 0 is measured before the line cycle because it needs to char\n // emptylines\n let maxHeight = this.getHeightOfChar(lineIndex, 0);\n for (let i = 1, len = this._textLines[lineIndex].length; i < len; i++) {\n maxHeight = Math.max(this.getHeightOfChar(lineIndex, i), maxHeight);\n }\n\n return (this.__lineHeights[lineIndex] =\n maxHeight * this.lineHeight * this._fontSizeMult);\n }\n\n /**\n * Calculate text box height\n */\n calcTextHeight() {\n let lineHeight,\n height = 0;\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n lineHeight = this.getHeightOfLine(i);\n height += i === len - 1 ? lineHeight / this.lineHeight : lineHeight;\n }\n return height;\n }\n\n /**\n * @private\n * @return {Number} Left offset\n */\n _getLeftOffset(): number {\n return this.direction === 'ltr' ? -this.width / 2 : this.width / 2;\n }\n\n /**\n * @private\n * @return {Number} Top offset\n */\n _getTopOffset(): number {\n return -this.height / 2;\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {String} method Method name (\"fillText\" or \"strokeText\")\n */\n _renderTextCommon(\n ctx: CanvasRenderingContext2D,\n method: 'fillText' | 'strokeText',\n ) {\n ctx.save();\n let lineHeights = 0;\n const left = this._getLeftOffset(),\n top = this._getTopOffset();\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i),\n maxHeight = heightOfLine / this.lineHeight,\n leftOffset = this._getLineLeftOffset(i);\n this._renderTextLine(\n method,\n ctx,\n this._textLines[i],\n left + leftOffset,\n top + lineHeights + maxHeight,\n i,\n );\n lineHeights += heightOfLine;\n }\n ctx.restore();\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextFill(ctx: CanvasRenderingContext2D) {\n if (!this.fill && !this.styleHas(FILL)) {\n return;\n }\n\n this._renderTextCommon(ctx, 'fillText');\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextStroke(ctx: CanvasRenderingContext2D) {\n if ((!this.stroke || this.strokeWidth === 0) && this.isEmptyStyles()) {\n return;\n }\n\n if (this.shadow && !this.shadow.affectStroke) {\n this._removeShadow(ctx);\n }\n\n ctx.save();\n this._setLineDash(ctx, this.strokeDashArray);\n ctx.beginPath();\n this._renderTextCommon(ctx, 'strokeText');\n ctx.closePath();\n ctx.restore();\n }\n\n /**\n * @private\n * @param {String} method fillText or strokeText.\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Array} line Content of the line, splitted in an array by grapheme\n * @param {Number} left\n * @param {Number} top\n * @param {Number} lineIndex\n */\n _renderChars(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n line: Array,\n left: number,\n top: number,\n lineIndex: number,\n ) {\n const lineHeight = this.getHeightOfLine(lineIndex),\n isJustify = this.textAlign.includes(JUSTIFY),\n path = this.path,\n shortCut =\n !isJustify &&\n this.charSpacing === 0 &&\n this.isEmptyStyles(lineIndex) &&\n !path,\n isLtr = this.direction === 'ltr',\n sign = this.direction === 'ltr' ? 1 : -1,\n // this was changed in the PR #7674\n // currentDirection = ctx.canvas.getAttribute('dir');\n currentDirection = ctx.direction;\n\n let actualStyle,\n nextStyle,\n charsToRender = '',\n charBox,\n boxWidth = 0,\n timeToRender,\n drawingLeft;\n\n ctx.save();\n if (currentDirection !== this.direction) {\n ctx.canvas.setAttribute('dir', isLtr ? 'ltr' : 'rtl');\n ctx.direction = isLtr ? 'ltr' : 'rtl';\n ctx.textAlign = isLtr ? LEFT : RIGHT;\n }\n top -= (lineHeight * this._fontSizeFraction) / this.lineHeight;\n if (shortCut) {\n // render all the line in one pass without checking\n // drawingLeft = isLtr ? left : left - this.getLineWidth(lineIndex);\n this._renderChar(method, ctx, lineIndex, 0, line.join(''), left, top);\n ctx.restore();\n return;\n }\n for (let i = 0, len = line.length - 1; i <= len; i++) {\n timeToRender = i === len || this.charSpacing || path;\n charsToRender += line[i];\n charBox = this.__charBounds[lineIndex][i] as Required;\n if (boxWidth === 0) {\n left += sign * (charBox.kernedWidth - charBox.width);\n boxWidth += charBox.width;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n if (isJustify && !timeToRender) {\n if (this._reSpaceAndTab.test(line[i])) {\n timeToRender = true;\n }\n }\n if (!timeToRender) {\n // if we have charSpacing, we render char by char\n actualStyle =\n actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n }\n if (timeToRender) {\n if (path) {\n ctx.save();\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n -boxWidth / 2,\n 0,\n );\n ctx.restore();\n } else {\n drawingLeft = left;\n this._renderChar(\n method,\n ctx,\n lineIndex,\n i,\n charsToRender,\n drawingLeft,\n top,\n );\n }\n charsToRender = '';\n actualStyle = nextStyle;\n left += sign * boxWidth;\n boxWidth = 0;\n }\n }\n ctx.restore();\n }\n\n /**\n * This function try to patch the missing gradientTransform on canvas gradients.\n * transforming a context to transform the gradient, is going to transform the stroke too.\n * we want to transform the gradient but not the stroke operation, so we create\n * a transformed gradient on a pattern and then we use the pattern instead of the gradient.\n * this method has drawbacks: is slow, is in low resolution, needs a patch for when the size\n * is limited.\n * @private\n * @param {TFiller} filler a fabric gradient instance\n * @return {CanvasPattern} a pattern to use as fill/stroke style\n */\n _applyPatternGradientTransformText(filler: TFiller) {\n // TODO: verify compatibility with strokeUniform\n const width = this.width + this.strokeWidth,\n height = this.height + this.strokeWidth,\n pCanvas = createCanvasElementFor({\n width,\n height,\n }),\n pCtx = pCanvas.getContext('2d')!;\n pCanvas.width = width;\n pCanvas.height = height;\n pCtx.beginPath();\n pCtx.moveTo(0, 0);\n pCtx.lineTo(width, 0);\n pCtx.lineTo(width, height);\n pCtx.lineTo(0, height);\n pCtx.closePath();\n pCtx.translate(width / 2, height / 2);\n pCtx.fillStyle = filler.toLive(pCtx)!;\n this._applyPatternGradientTransform(pCtx, filler);\n pCtx.fill();\n return pCtx.createPattern(pCanvas, 'no-repeat')!;\n }\n\n handleFiller(\n ctx: CanvasRenderingContext2D,\n property: `${T}Style`,\n filler: TFiller | string,\n ): { offsetX: number; offsetY: number } {\n let offsetX: number, offsetY: number;\n if (isFiller(filler)) {\n if (\n (filler as Gradient<'linear'>).gradientUnits === 'percentage' ||\n (filler as Gradient<'linear'>).gradientTransform ||\n (filler as Pattern).patternTransform\n ) {\n // need to transform gradient in a pattern.\n // this is a slow process. If you are hitting this codepath, and the object\n // is not using caching, you should consider switching it on.\n // we need a canvas as big as the current object caching canvas.\n offsetX = -this.width / 2;\n offsetY = -this.height / 2;\n ctx.translate(offsetX, offsetY);\n ctx[property] = this._applyPatternGradientTransformText(filler);\n return { offsetX, offsetY };\n } else {\n // is a simple gradient or pattern\n ctx[property] = filler.toLive(ctx)!;\n return this._applyPatternGradientTransform(ctx, filler);\n }\n } else {\n // is a color\n ctx[property] = filler;\n }\n return { offsetX: 0, offsetY: 0 };\n }\n\n /**\n * This function prepare the canvas for a stroke style, and stroke and strokeWidth\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with stroke and strokeWidth defined\n * @returns\n */\n _setStrokeStyles(\n ctx: CanvasRenderingContext2D,\n {\n stroke,\n strokeWidth,\n }: Pick,\n ) {\n ctx.lineWidth = strokeWidth;\n ctx.lineCap = this.strokeLineCap;\n ctx.lineDashOffset = this.strokeDashOffset;\n ctx.lineJoin = this.strokeLineJoin;\n ctx.miterLimit = this.strokeMiterLimit;\n return this.handleFiller(ctx, 'strokeStyle', stroke!);\n }\n\n /**\n * This function prepare the canvas for a ill style, and fill\n * need to be sent in as defined\n * @param {CanvasRenderingContext2D} ctx\n * @param {CompleteTextStyleDeclaration} style with ill defined\n * @returns\n */\n _setFillStyles(ctx: CanvasRenderingContext2D, { fill }: Pick) {\n return this.handleFiller(ctx, 'fillStyle', fill!);\n }\n\n /**\n * @private\n * @param {String} method\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {String} _char\n * @param {Number} left Left coordinate\n * @param {Number} top Top coordinate\n * @param {Number} lineHeight Height of the line\n */\n _renderChar(\n method: 'fillText' | 'strokeText',\n ctx: CanvasRenderingContext2D,\n lineIndex: number,\n charIndex: number,\n _char: string,\n left: number,\n top: number,\n ) {\n const decl = this._getStyleDeclaration(lineIndex, charIndex),\n fullDecl = this.getCompleteStyleDeclaration(lineIndex, charIndex),\n shouldFill = method === 'fillText' && fullDecl.fill,\n shouldStroke =\n method === 'strokeText' && fullDecl.stroke && fullDecl.strokeWidth;\n\n if (!shouldStroke && !shouldFill) {\n return;\n }\n ctx.save();\n\n ctx.font = this._getFontDeclaration(fullDecl);\n\n if (decl.textBackgroundColor) {\n this._removeShadow(ctx);\n }\n if (decl.deltaY) {\n top += decl.deltaY;\n }\n\n if (shouldFill) {\n const fillOffsets = this._setFillStyles(ctx, fullDecl);\n ctx.fillText(\n _char,\n left - fillOffsets.offsetX,\n top - fillOffsets.offsetY,\n );\n }\n\n if (shouldStroke) {\n const strokeOffsets = this._setStrokeStyles(ctx, fullDecl);\n ctx.strokeText(\n _char,\n left - strokeOffsets.offsetX,\n top - strokeOffsets.offsetY,\n );\n }\n\n ctx.restore();\n }\n\n /**\n * Turns the character into a 'superior figure' (i.e. 'superscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSuperscript(start: number, end: number) {\n this._setScript(start, end, this.superscript);\n }\n\n /**\n * Turns the character into an 'inferior figure' (i.e. 'subscript')\n * @param {Number} start selection start\n * @param {Number} end selection end\n */\n setSubscript(start: number, end: number) {\n this._setScript(start, end, this.subscript);\n }\n\n /**\n * Applies 'schema' at given position\n * @private\n * @param {Number} start selection start\n * @param {Number} end selection end\n * @param {Number} schema\n */\n protected _setScript(\n start: number,\n end: number,\n schema: {\n size: number;\n baseline: number;\n },\n ) {\n const loc = this.get2DCursorLocation(start, true),\n fontSize = this.getValueOfPropertyAt(\n loc.lineIndex,\n loc.charIndex,\n 'fontSize',\n ),\n dy = this.getValueOfPropertyAt(loc.lineIndex, loc.charIndex, 'deltaY'),\n style = {\n fontSize: fontSize * schema.size,\n deltaY: dy + fontSize * schema.baseline,\n };\n this.setSelectionStyles(style, start, end);\n }\n\n /**\n * @private\n * @param {Number} lineIndex index text line\n * @return {Number} Line left offset\n */\n _getLineLeftOffset(lineIndex: number): number {\n const lineWidth = this.getLineWidth(lineIndex),\n lineDiff = this.width - lineWidth,\n textAlign = this.textAlign,\n direction = this.direction,\n isEndOfWrapping = this.isEndOfWrapping(lineIndex);\n let leftOffset = 0;\n if (\n textAlign === JUSTIFY ||\n (textAlign === JUSTIFY_CENTER && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_RIGHT && !isEndOfWrapping) ||\n (textAlign === JUSTIFY_LEFT && !isEndOfWrapping)\n ) {\n return 0;\n }\n if (textAlign === CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === RIGHT) {\n leftOffset = lineDiff;\n }\n if (textAlign === JUSTIFY_CENTER) {\n leftOffset = lineDiff / 2;\n }\n if (textAlign === JUSTIFY_RIGHT) {\n leftOffset = lineDiff;\n }\n if (direction === 'rtl') {\n if (\n textAlign === RIGHT ||\n textAlign === JUSTIFY ||\n textAlign === JUSTIFY_RIGHT\n ) {\n leftOffset = 0;\n } else if (textAlign === LEFT || textAlign === JUSTIFY_LEFT) {\n leftOffset = -lineDiff;\n } else if (textAlign === CENTER || textAlign === JUSTIFY_CENTER) {\n leftOffset = -lineDiff / 2;\n }\n }\n return leftOffset;\n }\n\n /**\n * @private\n */\n _clearCache() {\n this._forceClearCache = false;\n this.__lineWidths = [];\n this.__lineHeights = [];\n this.__charBounds = [];\n }\n\n /**\n * Measure a single line given its index. Used to calculate the initial\n * text bounding box. The values are calculated and stored in __lineWidths cache.\n * @private\n * @param {Number} lineIndex line number\n * @return {Number} Line width\n */\n getLineWidth(lineIndex: number): number {\n if (this.__lineWidths[lineIndex] !== undefined) {\n return this.__lineWidths[lineIndex];\n }\n\n const { width } = this.measureLine(lineIndex);\n this.__lineWidths[lineIndex] = width;\n return width;\n }\n\n _getWidthOfCharSpacing() {\n if (this.charSpacing !== 0) {\n return (this.fontSize * this.charSpacing) / 1000;\n }\n return 0;\n }\n\n /**\n * Retrieves the value of property at given character position\n * @param {Number} lineIndex the line number\n * @param {Number} charIndex the character number\n * @param {String} property the property name\n * @returns the value of 'property'\n */\n getValueOfPropertyAt(\n lineIndex: number,\n charIndex: number,\n property: T,\n ): this[T] {\n const charStyle = this._getStyleDeclaration(lineIndex, charIndex);\n return (charStyle[property] ?? this[property]) as this[T];\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _renderTextDecoration(\n ctx: CanvasRenderingContext2D,\n type: 'underline' | 'linethrough' | 'overline',\n ) {\n if (!this[type] && !this.styleHas(type)) {\n return;\n }\n let topOffset = this._getTopOffset();\n const leftOffset = this._getLeftOffset(),\n path = this.path,\n charSpacing = this._getWidthOfCharSpacing(),\n offsetY = this.offsets[type];\n\n for (let i = 0, len = this._textLines.length; i < len; i++) {\n const heightOfLine = this.getHeightOfLine(i);\n if (!this[type] && !this.styleHas(type, i)) {\n topOffset += heightOfLine;\n continue;\n }\n const line = this._textLines[i];\n const maxHeight = heightOfLine / this.lineHeight;\n const lineLeftOffset = this._getLineLeftOffset(i);\n let boxStart = 0;\n let boxWidth = 0;\n let lastDecoration = this.getValueOfPropertyAt(i, 0, type);\n let lastFill = this.getValueOfPropertyAt(i, 0, FILL);\n let currentDecoration;\n let currentFill;\n const top = topOffset + maxHeight * (1 - this._fontSizeFraction);\n let size = this.getHeightOfChar(i, 0);\n let dy = this.getValueOfPropertyAt(i, 0, 'deltaY');\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n const charBox = this.__charBounds[i][j] as Required;\n currentDecoration = this.getValueOfPropertyAt(i, j, type);\n currentFill = this.getValueOfPropertyAt(i, j, FILL);\n const currentSize = this.getHeightOfChar(i, j);\n const currentDy = this.getValueOfPropertyAt(i, j, 'deltaY');\n if (path && currentDecoration && currentFill) {\n ctx.save();\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.translate(charBox.renderLeft, charBox.renderTop);\n ctx.rotate(charBox.angle);\n ctx.fillRect(\n -charBox.kernedWidth / 2,\n offsetY * currentSize + currentDy,\n charBox.kernedWidth,\n this.fontSize / 15,\n );\n ctx.restore();\n } else if (\n (currentDecoration !== lastDecoration ||\n currentFill !== lastFill ||\n currentSize !== size ||\n currentDy !== dy) &&\n boxWidth > 0\n ) {\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n if (lastDecoration && lastFill) {\n // bug? verify lastFill is a valid fill here.\n ctx.fillStyle = lastFill as string;\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth,\n this.fontSize / 15,\n );\n }\n boxStart = charBox.left;\n boxWidth = charBox.width;\n lastDecoration = currentDecoration;\n lastFill = currentFill;\n size = currentSize;\n dy = currentDy;\n } else {\n boxWidth += charBox.kernedWidth;\n }\n }\n let drawStart = leftOffset + lineLeftOffset + boxStart;\n if (this.direction === 'rtl') {\n drawStart = this.width - drawStart - boxWidth;\n }\n ctx.fillStyle = currentFill as string;\n currentDecoration &&\n currentFill &&\n ctx.fillRect(\n drawStart,\n top + offsetY * size + dy,\n boxWidth - charSpacing,\n this.fontSize / 15,\n );\n topOffset += heightOfLine;\n }\n // if there is text background color no\n // other shadows should be casted\n this._removeShadow(ctx);\n }\n\n /**\n * return font declaration string for canvas context\n * @param {Object} [styleObject] object\n * @returns {String} font declaration formatted for canvas context.\n */\n _getFontDeclaration(\n {\n fontFamily = this.fontFamily,\n fontStyle = this.fontStyle,\n fontWeight = this.fontWeight,\n fontSize = this.fontSize,\n }: Partial<\n Pick<\n TextStyleDeclaration,\n 'fontFamily' | 'fontStyle' | 'fontWeight' | 'fontSize'\n >\n > = {},\n forMeasuring?: boolean,\n ): string {\n const parsedFontFamily =\n fontFamily.includes(\"'\") ||\n fontFamily.includes('\"') ||\n fontFamily.includes(',') ||\n FabricText.genericFonts.includes(fontFamily.toLowerCase())\n ? fontFamily\n : `\"${fontFamily}\"`;\n return [\n fontStyle,\n fontWeight,\n `${forMeasuring ? this.CACHE_FONT_SIZE : fontSize}px`,\n parsedFontFamily,\n ].join(' ');\n }\n\n /**\n * Renders text instance on a specified context\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n if (!this.visible) {\n return;\n }\n if (\n this.canvas &&\n this.canvas.skipOffscreen &&\n !this.group &&\n !this.isOnScreen()\n ) {\n return;\n }\n if (this._forceClearCache) {\n this.initDimensions();\n }\n super.render(ctx);\n }\n\n /**\n * Override this method to customize grapheme splitting\n * @todo the util `graphemeSplit` needs to be injectable in some way.\n * is more comfortable to inject the correct util rather than having to override text\n * in the middle of the prototype chain\n * @param {string} value\n * @returns {string[]} array of graphemes\n */\n graphemeSplit(value: string): string[] {\n return graphemeSplit(value);\n }\n\n /**\n * Returns the text as an array of lines.\n * @param {String} text text to split\n * @returns Lines in the text\n */\n _splitTextIntoLines(text: string): TextLinesInfo {\n const lines = text.split(this._reNewline),\n newLines = new Array(lines.length),\n newLine = ['\\n'];\n let newText: string[] = [];\n for (let i = 0; i < lines.length; i++) {\n newLines[i] = this.graphemeSplit(lines[i]);\n newText = newText.concat(newLines[i], newLine);\n }\n newText.pop();\n return {\n _unwrappedLines: newLines,\n lines: lines,\n graphemeText: newText,\n graphemeLines: newLines,\n };\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return {\n ...super.toObject([...additionalProps, ...propertiesToInclude] as K[]),\n styles: stylesToArray(this.styles, this.text),\n ...(this.path ? { path: this.path.toObject() } : {}),\n };\n }\n\n set(key: string | any, value?: any) {\n const { textLayoutProperties } = this.constructor as typeof FabricText;\n super.set(key, value);\n let needsDims = false;\n let isAddingPath = false;\n if (typeof key === 'object') {\n for (const _key in key) {\n if (_key === 'path') {\n this.setPathInfo();\n }\n needsDims = needsDims || textLayoutProperties.includes(_key);\n isAddingPath = isAddingPath || _key === 'path';\n }\n } else {\n needsDims = textLayoutProperties.includes(key);\n isAddingPath = key === 'path';\n }\n if (isAddingPath) {\n this.setPathInfo();\n }\n if (needsDims && this.initialized) {\n this.initDimensions();\n this.setCoords();\n }\n return this;\n }\n\n /**\n * Returns complexity of an instance\n * @return {Number} complexity\n */\n complexity(): number {\n return 1;\n }\n\n /**\n * List of generic font families\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#generic-name\n */\n static genericFonts = [\n 'serif',\n 'sans-serif',\n 'monospace',\n 'cursive',\n 'fantasy',\n 'system-ui',\n 'ui-serif',\n 'ui-sans-serif',\n 'ui-monospace',\n 'ui-rounded',\n 'math',\n 'emoji',\n 'fangsong',\n ];\n\n /* _FROM_SVG_START_ */\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricText.fromElement})\n * @static\n * @memberOf Text\n * @see: http://www.w3.org/TR/SVG/text.html#TextElement\n */\n static ATTRIBUTE_NAMES = SHARED_ATTRIBUTES.concat(\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'font-family',\n 'font-style',\n 'font-weight',\n 'font-size',\n 'letter-spacing',\n 'text-decoration',\n 'text-anchor',\n );\n\n /**\n * Returns FabricText instance from an SVG element (not yet implemented)\n * @static\n * @memberOf Text\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable,\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n FabricText.ATTRIBUTE_NAMES,\n cssRules,\n );\n\n const {\n textAnchor = LEFT as typeof LEFT | typeof CENTER | typeof RIGHT,\n textDecoration = '',\n dx = 0,\n dy = 0,\n top = 0,\n left = 0,\n fontSize = DEFAULT_SVG_FONT_SIZE,\n strokeWidth = 1,\n ...restOfOptions\n } = { ...options, ...parsedAttributes };\n\n const textContent = (element.textContent || '')\n .replace(/^\\s+|\\s+$|\\n+/g, '')\n .replace(/\\s+/g, ' ');\n\n // this code here is probably the usual issue for SVG center find\n // this can later looked at again and probably removed.\n\n const text = new this(textContent, {\n left: left + dx,\n top: top + dy,\n underline: textDecoration.includes('underline'),\n overline: textDecoration.includes('overline'),\n linethrough: textDecoration.includes('line-through'),\n // we initialize this as 0\n strokeWidth: 0,\n fontSize,\n ...restOfOptions,\n }),\n textHeightScaleFactor = text.getScaledHeight() / text.height,\n lineHeightDiff =\n (text.height + text.strokeWidth) * text.lineHeight - text.height,\n scaledDiff = lineHeightDiff * textHeightScaleFactor,\n textHeight = text.getScaledHeight() + scaledDiff;\n\n let offX = 0;\n /*\n Adjust positioning:\n x/y attributes in SVG correspond to the bottom-left corner of text bounding box\n fabric output by default at top, left.\n */\n if (textAnchor === CENTER) {\n offX = text.getScaledWidth() / 2;\n }\n if (textAnchor === RIGHT) {\n offX = text.getScaledWidth();\n }\n text.set({\n left: text.left - offX,\n top:\n text.top -\n (textHeight - text.fontSize * (0.07 + text._fontSizeFraction)) /\n text.lineHeight,\n strokeWidth,\n });\n return text;\n }\n\n /* _FROM_SVG_END_ */\n\n /**\n * Returns FabricText instance from an object representation\n * @param {Object} object plain js Object to create an instance from\n * @returns {Promise}\n */\n static fromObject<\n T extends TOptions,\n S extends FabricText,\n >(object: T) {\n return this._fromObject(\n {\n ...object,\n styles: stylesFromArray(object.styles || {}, object.text),\n },\n {\n extraParam: 'text',\n },\n );\n }\n}\n\napplyMixins(FabricText, [TextSVGExportMixin]);\nclassRegistry.setClass(FabricText);\nclassRegistry.setSVGClass(FabricText);\n","import type {\n DragEventData,\n DropEventData,\n TPointerEvent,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { IText } from './IText';\nimport { setStyle } from '../../util/dom_style';\nimport { cloneStyles } from '../../util/internals/cloneStyles';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, NONE } from '../../constants';\n\n/**\n * #### Dragging IText/Textbox Lifecycle\n * - {@link start} is called from `mousedown` {@link IText#_mouseDownHandler} and determines if dragging should start by testing {@link isPointerOverSelection}\n * - if true `mousedown` {@link IText#_mouseDownHandler} is blocked to keep selection\n * - if the pointer moves, canvas fires numerous mousemove {@link Canvas#_onMouseMove} that we make sure **aren't** prevented ({@link IText#shouldStartDragging}) in order for the window to start a drag session\n * - once/if the session starts canvas calls {@link onDragStart} on the active object to determine if dragging should occur\n * - canvas fires relevant drag events that are handled by the handlers defined in this scope\n * - {@link end} is called from `mouseup` {@link IText#mouseUpHandler}, blocking IText default click behavior\n * - in case the drag session didn't occur, {@link end} handles a click, since logic to do so was blocked during `mousedown`\n */\nexport class DraggableTextDelegate {\n readonly target: IText;\n private __mouseDownInPlace = false;\n private __dragStartFired = false;\n private __isDraggingOver = false;\n private __dragStartSelection?: {\n selectionStart: number;\n selectionEnd: number;\n };\n private __dragImageDisposer?: VoidFunction;\n private _dispose?: () => void;\n\n constructor(target: IText) {\n this.target = target;\n const disposers = [\n this.target.on('dragenter', this.dragEnterHandler.bind(this)),\n this.target.on('dragover', this.dragOverHandler.bind(this)),\n this.target.on('dragleave', this.dragLeaveHandler.bind(this)),\n this.target.on('dragend', this.dragEndHandler.bind(this)),\n this.target.on('drop', this.dropHandler.bind(this)),\n ];\n this._dispose = () => {\n disposers.forEach((d) => d());\n this._dispose = undefined;\n };\n }\n\n isPointerOverSelection(e: TPointerEvent) {\n const target = this.target;\n const newSelection = target.getSelectionStartFromPointer(e);\n return (\n target.isEditing &&\n newSelection >= target.selectionStart &&\n newSelection <= target.selectionEnd &&\n target.selectionStart < target.selectionEnd\n );\n }\n\n /**\n * @public override this method to disable dragging and default to mousedown logic\n */\n start(e: TPointerEvent) {\n return (this.__mouseDownInPlace = this.isPointerOverSelection(e));\n }\n\n /**\n * @public override this method to disable dragging without discarding selection\n */\n isActive() {\n return this.__mouseDownInPlace;\n }\n\n /**\n * Ends interaction and sets cursor in case of a click\n * @returns true if was active\n */\n end(e: TPointerEvent) {\n const active = this.isActive();\n if (active && !this.__dragStartFired) {\n // mousedown has been blocked since `active` is true => cursor has not been set.\n // `__dragStartFired` is false => dragging didn't occur, pointer didn't move and is over selection.\n // meaning this is actually a click, `active` is a false positive.\n this.target.setCursorByClick(e);\n this.target.initDelayedCursor(true);\n }\n this.__mouseDownInPlace = false;\n this.__dragStartFired = false;\n this.__isDraggingOver = false;\n return active;\n }\n\n getDragStartSelection() {\n return this.__dragStartSelection;\n }\n\n /**\n * Override to customize the drag image\n * https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage\n */\n setDragImage(\n e: DragEvent,\n {\n selectionStart,\n selectionEnd,\n }: {\n selectionStart: number;\n selectionEnd: number;\n },\n ) {\n const target = this.target;\n const canvas = target.canvas!;\n const flipFactor = new Point(target.flipX ? -1 : 1, target.flipY ? -1 : 1);\n const boundaries = target._getCursorBoundaries(selectionStart);\n const selectionPosition = new Point(\n boundaries.left + boundaries.leftOffset,\n boundaries.top + boundaries.topOffset,\n ).multiply(flipFactor);\n const pos = selectionPosition.transform(target.calcTransformMatrix());\n const pointer = canvas.getScenePoint(e);\n const diff = pointer.subtract(pos);\n const retinaScaling = target.getCanvasRetinaScaling();\n const bbox = target.getBoundingRect();\n const correction = pos.subtract(new Point(bbox.left, bbox.top));\n const vpt = canvas.viewportTransform;\n const offset = correction.add(diff).transform(vpt, true);\n // prepare instance for drag image snapshot by making all non selected text invisible\n const bgc = target.backgroundColor;\n const styles = cloneStyles(target.styles);\n target.backgroundColor = '';\n const styleOverride = {\n stroke: 'transparent',\n fill: 'transparent',\n textBackgroundColor: 'transparent',\n };\n target.setSelectionStyles(styleOverride, 0, selectionStart);\n target.setSelectionStyles(styleOverride, selectionEnd, target.text.length);\n target.dirty = true;\n const dragImage = target.toCanvasElement({\n enableRetinaScaling: canvas.enableRetinaScaling,\n viewportTransform: true,\n });\n // restore values\n target.backgroundColor = bgc;\n target.styles = styles;\n target.dirty = true;\n // position drag image offscreen\n setStyle(dragImage, {\n position: 'fixed',\n left: `${-dragImage.width}px`,\n border: NONE,\n width: `${dragImage.width / retinaScaling}px`,\n height: `${dragImage.height / retinaScaling}px`,\n });\n this.__dragImageDisposer && this.__dragImageDisposer();\n this.__dragImageDisposer = () => {\n dragImage.remove();\n };\n getDocumentFromElement(\n (e.target || this.target.hiddenTextarea)! as HTMLElement,\n ).body.appendChild(dragImage);\n e.dataTransfer?.setDragImage(dragImage, offset.x, offset.y);\n }\n\n /**\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drag source\n */\n onDragStart(e: DragEvent): boolean {\n this.__dragStartFired = true;\n const target = this.target;\n const active = this.isActive();\n if (active && e.dataTransfer) {\n const selection = (this.__dragStartSelection = {\n selectionStart: target.selectionStart,\n selectionEnd: target.selectionEnd,\n });\n const value = target._text\n .slice(selection.selectionStart, selection.selectionEnd)\n .join('');\n const data = { text: target.text, value, ...selection };\n e.dataTransfer.setData('text/plain', value);\n e.dataTransfer.setData(\n 'application/fabric',\n JSON.stringify({\n value: value,\n styles: target.getSelectionStyles(\n selection.selectionStart,\n selection.selectionEnd,\n true,\n ),\n }),\n );\n e.dataTransfer.effectAllowed = 'copyMove';\n this.setDragImage(e, data);\n }\n target.abortCursorAnimation();\n return active;\n }\n\n /**\n * use {@link targetCanDrop} to respect overriding\n * @returns {boolean} determines whether {@link target} should/shouldn't become a drop target\n */\n canDrop(e: DragEvent): boolean {\n if (\n this.target.editable &&\n !this.target.getActiveControl() &&\n !e.defaultPrevented\n ) {\n if (this.isActive() && this.__dragStartSelection) {\n // drag source trying to drop over itself\n // allow dropping only outside of drag start selection\n const index = this.target.getSelectionStartFromPointer(e);\n const dragStartSelection = this.__dragStartSelection;\n return (\n index < dragStartSelection.selectionStart ||\n index > dragStartSelection.selectionEnd\n );\n }\n return true;\n }\n return false;\n }\n\n /**\n * in order to respect overriding {@link IText#canDrop} we call that instead of calling {@link canDrop} directly\n */\n protected targetCanDrop(e: DragEvent) {\n return this.target.canDrop(e);\n }\n\n dragEnterHandler({ e }: DragEventData) {\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n }\n }\n\n dragOverHandler(ev: DragEventData) {\n const { e } = ev;\n const canDrop = this.targetCanDrop(e);\n if (!this.__isDraggingOver && canDrop) {\n this.__isDraggingOver = true;\n } else if (this.__isDraggingOver && !canDrop) {\n // drop state has changed\n this.__isDraggingOver = false;\n }\n if (this.__isDraggingOver) {\n // can be dropped, inform browser\n e.preventDefault();\n // inform event subscribers\n ev.canDrop = true;\n ev.dropTarget = this.target;\n }\n }\n\n dragLeaveHandler() {\n if (this.__isDraggingOver || this.isActive()) {\n this.__isDraggingOver = false;\n }\n }\n\n /**\n * Override the `text/plain | application/fabric` types of {@link DragEvent#dataTransfer}\n * in order to change the drop value or to customize styling respectively, by listening to the `drop:before` event\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#performing_a_drop\n */\n dropHandler(ev: DropEventData) {\n const { e } = ev;\n const didDrop = e.defaultPrevented;\n this.__isDraggingOver = false;\n // inform browser that the drop has been accepted\n e.preventDefault();\n let insert = e.dataTransfer?.getData('text/plain');\n if (insert && !didDrop) {\n const target = this.target;\n const canvas = target.canvas!;\n let insertAt = target.getSelectionStartFromPointer(e);\n const { styles } = (\n e.dataTransfer!.types.includes('application/fabric')\n ? JSON.parse(e.dataTransfer!.getData('application/fabric'))\n : {}\n ) as { styles: TextStyleDeclaration[] };\n const trailing = insert[Math.max(0, insert.length - 1)];\n const selectionStartOffset = 0;\n // drag and drop in same instance\n if (this.__dragStartSelection) {\n const selectionStart = this.__dragStartSelection.selectionStart;\n const selectionEnd = this.__dragStartSelection.selectionEnd;\n if (insertAt > selectionStart && insertAt <= selectionEnd) {\n insertAt = selectionStart;\n } else if (insertAt > selectionEnd) {\n insertAt -= selectionEnd - selectionStart;\n }\n target.removeChars(selectionStart, selectionEnd);\n // prevent `dragend` from handling event\n delete this.__dragStartSelection;\n }\n // remove redundant line break\n if (\n target._reNewline.test(trailing) &&\n (target._reNewline.test(target._text[insertAt]) ||\n insertAt === target._text.length)\n ) {\n insert = insert.trimEnd();\n }\n // inform subscribers\n ev.didDrop = true;\n ev.dropTarget = target;\n // finalize\n target.insertChars(insert, styles, insertAt);\n // can this part be moved in an outside event? andrea to check.\n canvas.setActiveObject(target);\n target.enterEditing(e);\n target.selectionStart = Math.min(\n insertAt + selectionStartOffset,\n target._text.length,\n );\n target.selectionEnd = Math.min(\n target.selectionStart + insert.length,\n target._text.length,\n );\n target.hiddenTextarea!.value = target.text;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n target.fire(CHANGED, {\n index: insertAt + selectionStartOffset,\n action: 'drop',\n });\n canvas.fire('text:changed', { target });\n canvas.contextTopDirty = true;\n canvas.requestRenderAll();\n }\n }\n\n /**\n * fired only on the drag source after drop (if occurred)\n * handle changes to the drag source in case of a drop on another object or a cancellation\n * https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Drag_operations#finishing_a_drag\n */\n dragEndHandler({ e }: DragEventData) {\n if (this.isActive() && this.__dragStartFired) {\n // once the drop event finishes we check if we need to change the drag source\n // if the drag source received the drop we bail out since the drop handler has already handled logic\n if (this.__dragStartSelection) {\n const target = this.target;\n const canvas = this.target.canvas!;\n const { selectionStart, selectionEnd } = this.__dragStartSelection;\n const dropEffect = e.dataTransfer?.dropEffect || NONE;\n if (dropEffect === NONE) {\n // pointer is back over selection\n target.selectionStart = selectionStart;\n target.selectionEnd = selectionEnd;\n target._updateTextarea();\n target.hiddenTextarea!.focus();\n } else {\n target.clearContextTop();\n if (dropEffect === 'move') {\n target.removeChars(selectionStart, selectionEnd);\n target.selectionStart = target.selectionEnd = selectionStart;\n target.hiddenTextarea &&\n (target.hiddenTextarea.value = target.text);\n target._updateTextarea();\n target.fire(CHANGED, {\n index: selectionStart,\n action: 'dragend',\n });\n canvas.fire('text:changed', { target });\n canvas.requestRenderAll();\n }\n target.exitEditing();\n }\n }\n }\n\n this.__dragImageDisposer && this.__dragImageDisposer();\n delete this.__dragImageDisposer;\n delete this.__dragStartSelection;\n this.__isDraggingOver = false;\n }\n\n dispose() {\n this._dispose && this._dispose();\n }\n}\n","import type {\n ObjectEvents,\n TPointerEvent,\n TPointerEventInfo,\n} from '../../EventTypeDefs';\nimport { Point } from '../../Point';\nimport type { FabricObject } from '../Object/FabricObject';\nimport { FabricText } from '../Text/Text';\nimport { animate } from '../../util/animation/animate';\nimport type { TOnAnimationChangeCallback } from '../../util/animation/types';\nimport type { ValueAnimation } from '../../util/animation/ValueAnimation';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport type { TOptions } from '../../typedefs';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { LEFT, MODIFIED, RIGHT, reNewline } from '../../constants';\nimport type { IText } from './IText';\n\n/**\n * extend this regex to support non english languages\n *\n * - ` ` Matches a SPACE character (char code 32).\n * - `\\n` Matches a LINE FEED character (char code 10).\n * - `\\.` Matches a \".\" character (char code 46).\n * - `,` Matches a \",\" character (char code 44).\n * - `;` Matches a \";\" character (char code 59).\n * - `!` Matches a \"!\" character (char code 33).\n * - `\\?` Matches a \"?\" character (char code 63).\n * - `\\-` Matches a \"-\" character (char code 45).\n */\n// eslint-disable-next-line no-useless-escape\nconst reNonWord = /[ \\n\\.,;!\\?\\-]/;\n\nexport type ITextEvents = ObjectEvents & {\n 'selection:changed': never;\n changed: never | { index: number; action: string };\n tripleclick: TPointerEventInfo;\n 'editing:entered': never | { e: TPointerEvent };\n 'editing:exited': never;\n};\n\nexport abstract class ITextBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends FabricText {\n declare abstract isEditing: boolean;\n declare abstract cursorDelay: number;\n declare abstract selectionStart: number;\n declare abstract selectionEnd: number;\n declare abstract cursorDuration: number;\n declare abstract editable: boolean;\n declare abstract editingBorderColor: string;\n\n declare abstract compositionStart: number;\n declare abstract compositionEnd: number;\n\n declare abstract hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * Helps determining when the text is in composition, so that the cursor\n * rendering is altered.\n */\n protected declare inCompositionMode: boolean;\n\n protected declare _reSpace: RegExp;\n private declare _currentTickState?: ValueAnimation;\n private declare _currentTickCompleteState?: ValueAnimation;\n protected _currentCursorOpacity = 1;\n private declare _textBeforeEdit: string;\n protected declare __selectionStartOnMouseDown: number;\n\n protected declare selected: boolean;\n protected declare cursorOffsetCache: { left?: number; top?: number };\n protected declare _savedProps?: {\n hasControls: boolean;\n borderColor: string;\n lockMovementX: boolean;\n lockMovementY: boolean;\n selectable: boolean;\n hoverCursor: CSSStyleDeclaration['cursor'] | null;\n defaultCursor?: CSSStyleDeclaration['cursor'];\n moveCursor?: CSSStyleDeclaration['cursor'];\n };\n protected declare _selectionDirection: 'left' | 'right' | null;\n\n abstract initHiddenTextarea(): void;\n abstract _fireSelectionChanged(): void;\n abstract renderCursorOrSelection(): void;\n abstract getSelectionStartFromPointer(e: TPointerEvent): number;\n abstract _getCursorBoundaries(\n index: number,\n skipCaching?: boolean,\n ): {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n };\n\n /**\n * Initializes all the interactive behavior of IText\n */\n initBehavior() {\n this._tick = this._tick.bind(this);\n this._onTickComplete = this._onTickComplete.bind(this);\n this.updateSelectionOnMouseMove =\n this.updateSelectionOnMouseMove.bind(this);\n }\n\n onDeselect(options?: { e?: TPointerEvent; object?: FabricObject }) {\n this.isEditing && this.exitEditing();\n this.selected = false;\n return super.onDeselect(options);\n }\n\n /**\n * @private\n */\n _animateCursor({\n toValue,\n duration,\n delay,\n onComplete,\n }: {\n toValue: number;\n duration: number;\n delay?: number;\n onComplete?: TOnAnimationChangeCallback;\n }) {\n return animate({\n startValue: this._currentCursorOpacity,\n endValue: toValue,\n duration,\n delay,\n onComplete,\n abort: () =>\n !this.canvas ||\n // we do not want to animate a selection, only cursor\n this.selectionStart !== this.selectionEnd,\n onChange: (value) => {\n this._currentCursorOpacity = value;\n this.renderCursorOrSelection();\n },\n });\n }\n\n /**\n * changes the cursor from visible to invisible\n */\n private _tick(delay?: number) {\n this._currentTickState = this._animateCursor({\n toValue: 0,\n duration: this.cursorDuration / 2,\n delay: Math.max(delay || 0, 100),\n onComplete: this._onTickComplete,\n });\n }\n\n /**\n * Changes the cursor from invisible to visible\n */\n private _onTickComplete() {\n this._currentTickCompleteState?.abort();\n this._currentTickCompleteState = this._animateCursor({\n toValue: 1,\n duration: this.cursorDuration,\n onComplete: this._tick,\n });\n }\n\n /**\n * Initializes delayed cursor\n */\n initDelayedCursor(restart?: boolean) {\n this.abortCursorAnimation();\n this._tick(restart ? 0 : this.cursorDelay);\n }\n\n /**\n * Aborts cursor animation, clears all timeouts and clear textarea context if necessary\n */\n abortCursorAnimation() {\n let shouldClear = false;\n [this._currentTickState, this._currentTickCompleteState].forEach(\n (cursorAnimation) => {\n if (cursorAnimation && !cursorAnimation.isDone()) {\n shouldClear = true;\n cursorAnimation.abort();\n }\n },\n );\n\n this._currentCursorOpacity = 1;\n\n // make sure we clear context even if instance is not editing\n if (shouldClear) {\n this.clearContextTop();\n }\n }\n\n /**\n * Restart tue cursor animation if either is in complete state ( between animations )\n * or if it never started before\n */\n restartCursorIfNeeded() {\n if (\n [this._currentTickState, this._currentTickCompleteState].some(\n (cursorAnimation) => !cursorAnimation || cursorAnimation.isDone(),\n )\n ) {\n this.initDelayedCursor();\n }\n }\n\n /**\n * Selects entire text\n */\n selectAll() {\n this.selectionStart = 0;\n this.selectionEnd = this._text.length;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Returns selected text\n * @return {String}\n */\n getSelectedText(): string {\n return this._text.slice(this.selectionStart, this.selectionEnd).join('');\n }\n\n /**\n * Find new selection index representing start of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n // remove space before cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index--;\n }\n }\n while (/\\S/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current word according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findWordBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n // remove space after cursor first\n if (this._reSpace.test(this._text[index])) {\n while (this._reSpace.test(this._text[index])) {\n offset++;\n index++;\n }\n }\n while (/\\S/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Find new selection index representing start of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryLeft(startFrom: number): number {\n let offset = 0,\n index = startFrom - 1;\n\n while (!/\\n/.test(this._text[index]) && index > -1) {\n offset++;\n index--;\n }\n\n return startFrom - offset;\n }\n\n /**\n * Find new selection index representing end of current line according to current selection index\n * @param {Number} startFrom Current selection index\n * @return {Number} New selection index\n */\n findLineBoundaryRight(startFrom: number): number {\n let offset = 0,\n index = startFrom;\n\n while (!/\\n/.test(this._text[index]) && index < this._text.length) {\n offset++;\n index++;\n }\n\n return startFrom + offset;\n }\n\n /**\n * Finds index corresponding to beginning or end of a word\n * @param {Number} selectionStart Index of a character\n * @param {Number} direction 1 or -1\n * @return {Number} Index of the beginning or end of a word\n */\n searchWordBoundary(selectionStart: number, direction: 1 | -1): number {\n const text = this._text;\n // if we land on a space we move the cursor backwards\n // if we are searching boundary end we move the cursor backwards ONLY if we don't land on a line break\n let index =\n selectionStart > 0 &&\n this._reSpace.test(text[selectionStart]) &&\n (direction === -1 || !reNewline.test(text[selectionStart - 1]))\n ? selectionStart - 1\n : selectionStart,\n _char = text[index];\n while (index > 0 && index < text.length && !reNonWord.test(_char)) {\n index += direction;\n _char = text[index];\n }\n if (direction === -1 && reNonWord.test(_char)) {\n index++;\n }\n return index;\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a word based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectWord(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n // search backwards\n const newSelectionStart = this.searchWordBoundary(selectionStart, -1),\n // search forward\n newSelectionEnd = Math.max(\n newSelectionStart,\n this.searchWordBoundary(selectionStart, 1),\n );\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n\n /**\n * TODO fix: selectionStart set as 0 will be ignored?\n * Selects a line based on the index\n * @param {Number} selectionStart Index of a character\n */\n selectLine(selectionStart?: number) {\n selectionStart = selectionStart || this.selectionStart;\n const newSelectionStart = this.findLineBoundaryLeft(selectionStart),\n newSelectionEnd = this.findLineBoundaryRight(selectionStart);\n\n this.selectionStart = newSelectionStart;\n this.selectionEnd = newSelectionEnd;\n this._fireSelectionChanged();\n this._updateTextarea();\n return this;\n }\n\n /**\n * Enters editing state\n */\n enterEditing(e?: TPointerEvent) {\n if (this.isEditing || !this.editable) {\n return;\n }\n this.enterEditingImpl();\n this.fire('editing:entered', e ? { e } : undefined);\n this._fireSelectionChanged();\n if (this.canvas) {\n this.canvas.fire('text:editing:entered', {\n target: this as unknown as IText,\n e,\n });\n this.canvas.requestRenderAll();\n }\n }\n\n /**\n * runs the actual logic that enter from editing state, see {@link enterEditing}\n */\n enterEditingImpl() {\n if (this.canvas) {\n this.canvas.calcOffset();\n this.canvas.textEditingManager.exitTextEditing();\n }\n\n this.isEditing = true;\n\n this.initHiddenTextarea();\n this.hiddenTextarea!.focus();\n this.hiddenTextarea!.value = this.text;\n this._updateTextarea();\n this._saveEditingProps();\n this._setEditingProps();\n this._textBeforeEdit = this.text;\n\n this._tick();\n }\n\n /**\n * called by {@link Canvas#textEditingManager}\n */\n updateSelectionOnMouseMove(e: TPointerEvent) {\n if (this.getActiveControl()) {\n return;\n }\n\n const el = this.hiddenTextarea!;\n // regain focus\n getDocumentFromElement(el).activeElement !== el && el.focus();\n\n const newSelectionStart = this.getSelectionStartFromPointer(e),\n currentStart = this.selectionStart,\n currentEnd = this.selectionEnd;\n if (\n (newSelectionStart !== this.__selectionStartOnMouseDown ||\n currentStart === currentEnd) &&\n (currentStart === newSelectionStart || currentEnd === newSelectionStart)\n ) {\n return;\n }\n if (newSelectionStart > this.__selectionStartOnMouseDown) {\n this.selectionStart = this.__selectionStartOnMouseDown;\n this.selectionEnd = newSelectionStart;\n } else {\n this.selectionStart = newSelectionStart;\n this.selectionEnd = this.__selectionStartOnMouseDown;\n }\n if (\n this.selectionStart !== currentStart ||\n this.selectionEnd !== currentEnd\n ) {\n this._fireSelectionChanged();\n this._updateTextarea();\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * @private\n */\n _setEditingProps() {\n this.hoverCursor = 'text';\n\n if (this.canvas) {\n this.canvas.defaultCursor = this.canvas.moveCursor = 'text';\n }\n\n this.borderColor = this.editingBorderColor;\n this.hasControls = this.selectable = false;\n this.lockMovementX = this.lockMovementY = true;\n }\n\n /**\n * convert from textarea to grapheme indexes\n */\n fromStringToGraphemeSelection(start: number, end: number, text: string) {\n const smallerTextStart = text.slice(0, start),\n graphemeStart = this.graphemeSplit(smallerTextStart).length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = text.slice(start, end),\n graphemeEnd = this.graphemeSplit(smallerTextEnd).length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * convert from fabric to textarea values\n */\n fromGraphemeToStringSelection(\n start: number,\n end: number,\n graphemes: string[],\n ) {\n const smallerTextStart = graphemes.slice(0, start),\n graphemeStart = smallerTextStart.join('').length;\n if (start === end) {\n return { selectionStart: graphemeStart, selectionEnd: graphemeStart };\n }\n const smallerTextEnd = graphemes.slice(start, end),\n graphemeEnd = smallerTextEnd.join('').length;\n return {\n selectionStart: graphemeStart,\n selectionEnd: graphemeStart + graphemeEnd,\n };\n }\n\n /**\n * @private\n */\n _updateTextarea() {\n this.cursorOffsetCache = {};\n if (!this.hiddenTextarea) {\n return;\n }\n if (!this.inCompositionMode) {\n const newSelection = this.fromGraphemeToStringSelection(\n this.selectionStart,\n this.selectionEnd,\n this._text,\n );\n this.hiddenTextarea.selectionStart = newSelection.selectionStart;\n this.hiddenTextarea.selectionEnd = newSelection.selectionEnd;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateFromTextArea() {\n if (!this.hiddenTextarea) {\n return;\n }\n this.cursorOffsetCache = {};\n const textarea = this.hiddenTextarea;\n this.text = textarea.value;\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n const newSelection = this.fromStringToGraphemeSelection(\n textarea.selectionStart,\n textarea.selectionEnd,\n textarea.value,\n );\n this.selectionEnd = this.selectionStart = newSelection.selectionEnd;\n if (!this.inCompositionMode) {\n this.selectionStart = newSelection.selectionStart;\n }\n this.updateTextareaPosition();\n }\n\n /**\n * @private\n */\n updateTextareaPosition() {\n if (this.selectionStart === this.selectionEnd) {\n const style = this._calcTextareaPosition();\n this.hiddenTextarea!.style.left = style.left;\n this.hiddenTextarea!.style.top = style.top;\n }\n }\n\n /**\n * @private\n * @return {Object} style contains style for hiddenTextarea\n */\n _calcTextareaPosition() {\n if (!this.canvas) {\n return { left: '1px', top: '1px' };\n }\n const desiredPosition = this.inCompositionMode\n ? this.compositionStart\n : this.selectionStart,\n boundaries = this._getCursorBoundaries(desiredPosition),\n cursorLocation = this.get2DCursorLocation(desiredPosition),\n lineIndex = cursorLocation.lineIndex,\n charIndex = cursorLocation.charIndex,\n charHeight =\n this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize') *\n this.lineHeight,\n leftOffset = boundaries.leftOffset,\n retinaScaling = this.getCanvasRetinaScaling(),\n upperCanvas = this.canvas.upperCanvasEl,\n upperCanvasWidth = upperCanvas.width / retinaScaling,\n upperCanvasHeight = upperCanvas.height / retinaScaling,\n maxWidth = upperCanvasWidth - charHeight,\n maxHeight = upperCanvasHeight - charHeight;\n\n const p = new Point(\n boundaries.left + leftOffset,\n boundaries.top + boundaries.topOffset + charHeight,\n )\n .transform(this.calcTransformMatrix())\n .transform(this.canvas.viewportTransform)\n .multiply(\n new Point(\n upperCanvas.clientWidth / upperCanvasWidth,\n upperCanvas.clientHeight / upperCanvasHeight,\n ),\n );\n\n if (p.x < 0) {\n p.x = 0;\n }\n if (p.x > maxWidth) {\n p.x = maxWidth;\n }\n if (p.y < 0) {\n p.y = 0;\n }\n if (p.y > maxHeight) {\n p.y = maxHeight;\n }\n\n // add canvas offset on document\n p.x += this.canvas._offset.left;\n p.y += this.canvas._offset.top;\n\n return {\n left: `${p.x}px`,\n top: `${p.y}px`,\n fontSize: `${charHeight}px`,\n charHeight: charHeight,\n };\n }\n\n /**\n * @private\n */\n _saveEditingProps() {\n this._savedProps = {\n hasControls: this.hasControls,\n borderColor: this.borderColor,\n lockMovementX: this.lockMovementX,\n lockMovementY: this.lockMovementY,\n hoverCursor: this.hoverCursor,\n selectable: this.selectable,\n defaultCursor: this.canvas && this.canvas.defaultCursor,\n moveCursor: this.canvas && this.canvas.moveCursor,\n };\n }\n\n /**\n * @private\n */\n _restoreEditingProps() {\n if (!this._savedProps) {\n return;\n }\n\n this.hoverCursor = this._savedProps.hoverCursor;\n this.hasControls = this._savedProps.hasControls;\n this.borderColor = this._savedProps.borderColor;\n this.selectable = this._savedProps.selectable;\n this.lockMovementX = this._savedProps.lockMovementX;\n this.lockMovementY = this._savedProps.lockMovementY;\n\n if (this.canvas) {\n this.canvas.defaultCursor =\n this._savedProps.defaultCursor || this.canvas.defaultCursor;\n this.canvas.moveCursor =\n this._savedProps.moveCursor || this.canvas.moveCursor;\n }\n\n delete this._savedProps;\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * Please use exitEditingImpl, this function was kept to avoid breaking changes.\n * Will be removed in fabric 7.0\n * @deprecated use \"exitEditingImpl\"\n */\n protected _exitEditing() {\n const hiddenTextarea = this.hiddenTextarea;\n this.selected = false;\n this.isEditing = false;\n\n if (hiddenTextarea) {\n hiddenTextarea.blur && hiddenTextarea.blur();\n hiddenTextarea.parentNode &&\n hiddenTextarea.parentNode.removeChild(hiddenTextarea);\n }\n this.hiddenTextarea = null;\n this.abortCursorAnimation();\n this.selectionStart !== this.selectionEnd && this.clearContextTop();\n }\n\n /**\n * runs the actual logic that exits from editing state, see {@link exitEditing}\n * But it does not fire events\n */\n exitEditingImpl() {\n this._exitEditing();\n this.selectionEnd = this.selectionStart;\n this._restoreEditingProps();\n if (this._forceClearCache) {\n this.initDimensions();\n this.setCoords();\n }\n }\n\n /**\n * Exits from editing state and fires relevant events\n */\n exitEditing() {\n const isTextChanged = this._textBeforeEdit !== this.text;\n this.exitEditingImpl();\n\n this.fire('editing:exited');\n isTextChanged && this.fire(MODIFIED);\n if (this.canvas) {\n this.canvas.fire('text:editing:exited', {\n target: this as unknown as IText,\n });\n // todo: evaluate add an action to this event\n isTextChanged && this.canvas.fire('object:modified', { target: this });\n }\n return this;\n }\n\n /**\n * @private\n */\n _removeExtraneousStyles() {\n for (const prop in this.styles) {\n if (!this._textLines[prop as unknown as number]) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * remove and reflow a style block from start to end.\n * @param {Number} start linear start position for removal (included in removal)\n * @param {Number} end linear end position for removal ( excluded from removal )\n */\n removeStyleFromTo(start: number, end: number) {\n const { lineIndex: lineStart, charIndex: charStart } =\n this.get2DCursorLocation(start, true),\n { lineIndex: lineEnd, charIndex: charEnd } = this.get2DCursorLocation(\n end,\n true,\n );\n if (lineStart !== lineEnd) {\n // step1 remove the trailing of lineStart\n if (this.styles[lineStart]) {\n for (\n let i = charStart;\n i < this._unwrappedTextLines[lineStart].length;\n i++\n ) {\n delete this.styles[lineStart][i];\n }\n }\n // step2 move the trailing of lineEnd to lineStart if needed\n if (this.styles[lineEnd]) {\n for (\n let i = charEnd;\n i < this._unwrappedTextLines[lineEnd].length;\n i++\n ) {\n const styleObj = this.styles[lineEnd][i];\n if (styleObj) {\n this.styles[lineStart] || (this.styles[lineStart] = {});\n this.styles[lineStart][charStart + i - charEnd] = styleObj;\n }\n }\n }\n // step3 detects lines will be completely removed.\n for (let i = lineStart + 1; i <= lineEnd; i++) {\n delete this.styles[i];\n }\n // step4 shift remaining lines.\n this.shiftLineStyles(lineEnd, lineStart - lineEnd);\n } else {\n // remove and shift left on the same line\n if (this.styles[lineStart]) {\n const styleObj = this.styles[lineStart];\n const diff = charEnd - charStart;\n for (let i = charStart; i < charEnd; i++) {\n delete styleObj[i];\n }\n for (const char in this.styles[lineStart]) {\n const numericChar = parseInt(char, 10);\n if (numericChar >= charEnd) {\n styleObj[numericChar - diff] = styleObj[char];\n delete styleObj[char];\n }\n }\n }\n }\n }\n\n /**\n * Shifts line styles up or down\n * @param {Number} lineIndex Index of a line\n * @param {Number} offset Can any number?\n */\n shiftLineStyles(lineIndex: number, offset: number) {\n const clonedStyles = Object.assign({}, this.styles);\n for (const line in this.styles) {\n const numericLine = parseInt(line, 10);\n if (numericLine > lineIndex) {\n this.styles[numericLine + offset] = clonedStyles[numericLine];\n if (!clonedStyles[numericLine - offset]) {\n delete this.styles[numericLine];\n }\n }\n }\n }\n\n /**\n * Handle insertion of more consecutive style lines for when one or more\n * newlines gets added to the text. Since current style needs to be shifted\n * first we shift the current style of the number lines needed, then we add\n * new lines from the last to the first.\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} qty number of lines to add\n * @param {Array} copiedStyle Array of objects styles\n */\n insertNewlineStyleObject(\n lineIndex: number,\n charIndex: number,\n qty: number,\n copiedStyle?: { [index: number]: TextStyleDeclaration },\n ) {\n const newLineStyles: { [index: number]: TextStyleDeclaration } = {};\n const originalLineLength = this._unwrappedTextLines[lineIndex].length;\n const isEndOfLine = originalLineLength === charIndex;\n\n let someStyleIsCarryingOver = false;\n qty || (qty = 1);\n this.shiftLineStyles(lineIndex, qty);\n const currentCharStyle = this.styles[lineIndex]\n ? this.styles[lineIndex][charIndex === 0 ? charIndex : charIndex - 1]\n : undefined;\n\n // we clone styles of all chars\n // after cursor onto the current line\n for (const index in this.styles[lineIndex]) {\n const numIndex = parseInt(index, 10);\n if (numIndex >= charIndex) {\n someStyleIsCarryingOver = true;\n newLineStyles[numIndex - charIndex] = this.styles[lineIndex][index];\n // remove lines from the previous line since they're on a new line now\n if (!(isEndOfLine && charIndex === 0)) {\n delete this.styles[lineIndex][index];\n }\n }\n }\n let styleCarriedOver = false;\n if (someStyleIsCarryingOver && !isEndOfLine) {\n // if is end of line, the extra style we copied\n // is probably not something we want\n this.styles[lineIndex + qty] = newLineStyles;\n styleCarriedOver = true;\n }\n if (styleCarriedOver || originalLineLength > charIndex) {\n // skip the last line of since we already prepared it.\n // or contains text without style that we don't want to style\n // just because it changed lines\n qty--;\n }\n // for the all the lines or all the other lines\n // we clone current char style onto the next (otherwise empty) line\n while (qty > 0) {\n if (copiedStyle && copiedStyle[qty - 1]) {\n this.styles[lineIndex + qty] = {\n 0: { ...copiedStyle[qty - 1] },\n };\n } else if (currentCharStyle) {\n this.styles[lineIndex + qty] = {\n 0: { ...currentCharStyle },\n };\n } else {\n delete this.styles[lineIndex + qty];\n }\n qty--;\n }\n this._forceClearCache = true;\n }\n\n /**\n * Inserts style object for a given line/char index\n * @param {Number} lineIndex Index of a line\n * @param {Number} charIndex Index of a char\n * @param {Number} quantity number Style object to insert, if given\n * @param {Array} copiedStyle array of style objects\n */\n insertCharStyleObject(\n lineIndex: number,\n charIndex: number,\n quantity: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n if (!this.styles) {\n this.styles = {};\n }\n const currentLineStyles = this.styles[lineIndex],\n currentLineStylesCloned = currentLineStyles\n ? { ...currentLineStyles }\n : {};\n\n quantity || (quantity = 1);\n // shift all char styles by quantity forward\n // 0,1,2,3 -> (charIndex=2) -> 0,1,3,4 -> (insert 2) -> 0,1,2,3,4\n for (const index in currentLineStylesCloned) {\n const numericIndex = parseInt(index, 10);\n if (numericIndex >= charIndex) {\n currentLineStyles[numericIndex + quantity] =\n currentLineStylesCloned[numericIndex];\n // only delete the style if there was nothing moved there\n if (!currentLineStylesCloned[numericIndex - quantity]) {\n delete currentLineStyles[numericIndex];\n }\n }\n }\n this._forceClearCache = true;\n if (copiedStyle) {\n while (quantity--) {\n if (!Object.keys(copiedStyle[quantity]).length) {\n continue;\n }\n if (!this.styles[lineIndex]) {\n this.styles[lineIndex] = {};\n }\n this.styles[lineIndex][charIndex + quantity] = {\n ...copiedStyle[quantity],\n };\n }\n return;\n }\n if (!currentLineStyles) {\n return;\n }\n const newStyle = currentLineStyles[charIndex ? charIndex - 1 : 1];\n while (newStyle && quantity--) {\n this.styles[lineIndex][charIndex + quantity] = { ...newStyle };\n }\n }\n\n /**\n * Inserts style object(s)\n * @param {Array} insertedText Characters at the location where style is inserted\n * @param {Number} start cursor index for inserting style\n * @param {Array} [copiedStyle] array of style objects to insert.\n */\n insertNewStyleBlock(\n insertedText: string[],\n start: number,\n copiedStyle?: TextStyleDeclaration[],\n ) {\n const cursorLoc = this.get2DCursorLocation(start, true),\n addedLines = [0];\n let linesLength = 0;\n // get an array of how many char per lines are being added.\n for (let i = 0; i < insertedText.length; i++) {\n if (insertedText[i] === '\\n') {\n linesLength++;\n addedLines[linesLength] = 0;\n } else {\n addedLines[linesLength]++;\n }\n }\n // for the first line copy the style from the current char position.\n if (addedLines[0] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex,\n addedLines[0],\n copiedStyle,\n );\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[0] + 1);\n }\n linesLength &&\n this.insertNewlineStyleObject(\n cursorLoc.lineIndex,\n cursorLoc.charIndex + addedLines[0],\n linesLength,\n );\n let i;\n for (i = 1; i < linesLength; i++) {\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n } else if (copiedStyle) {\n // this test is required in order to close #6841\n // when a pasted buffer begins with a newline then\n // this.styles[cursorLoc.lineIndex + i] and copiedStyle[0]\n // may be undefined for some reason\n if (this.styles[cursorLoc.lineIndex + i] && copiedStyle[0]) {\n this.styles[cursorLoc.lineIndex + i][0] = copiedStyle[0];\n }\n }\n copiedStyle = copiedStyle && copiedStyle.slice(addedLines[i] + 1);\n }\n if (addedLines[i] > 0) {\n this.insertCharStyleObject(\n cursorLoc.lineIndex + i,\n 0,\n addedLines[i],\n copiedStyle,\n );\n }\n }\n\n /**\n * Removes characters from start/end\n * start/end ar per grapheme position in _text array.\n *\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n removeChars(start: number, end: number = start + 1) {\n this.removeStyleFromTo(start, end);\n this._text.splice(start, end - start);\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * insert characters at start position, before start position.\n * start equal 1 it means the text get inserted between actual grapheme 0 and 1\n * if style array is provided, it must be as the same length of text in graphemes\n * if end is provided and is bigger than start, old text is replaced.\n * start/end ar per grapheme position in _text array.\n *\n * @param {String} text text to insert\n * @param {Array} style array of style objects\n * @param {Number} start\n * @param {Number} end default to start + 1\n */\n insertChars(\n text: string,\n style: TextStyleDeclaration[] | undefined,\n start: number,\n end: number = start,\n ) {\n if (end > start) {\n this.removeStyleFromTo(start, end);\n }\n const graphemes = this.graphemeSplit(text);\n this.insertNewStyleBlock(graphemes, start, style);\n this._text = [\n ...this._text.slice(0, start),\n ...graphemes,\n ...this._text.slice(end),\n ];\n this.text = this._text.join('');\n this.set('dirty', true);\n this.initDimensions();\n this.setCoords();\n this._removeExtraneousStyles();\n }\n\n /**\n * Set the selectionStart and selectionEnd according to the new position of cursor\n * mimic the key - mouse navigation when shift is pressed.\n */\n setSelectionStartEndWithShift(\n start: number,\n end: number,\n newSelection: number,\n ) {\n if (newSelection <= start) {\n if (end === start) {\n this._selectionDirection = LEFT;\n } else if (this._selectionDirection === RIGHT) {\n this._selectionDirection = LEFT;\n this.selectionEnd = start;\n }\n this.selectionStart = newSelection;\n } else if (newSelection > start && newSelection < end) {\n if (this._selectionDirection === RIGHT) {\n this.selectionEnd = newSelection;\n } else {\n this.selectionStart = newSelection;\n }\n } else {\n // newSelection is > selection start and end\n if (end === start) {\n this._selectionDirection = RIGHT;\n } else if (this._selectionDirection === LEFT) {\n this._selectionDirection = RIGHT;\n this.selectionStart = end;\n }\n this.selectionEnd = newSelection;\n }\n }\n}\n","import { config } from '../../config';\nimport { getFabricDocument, getEnv } from '../../env';\nimport { capValue } from '../../util/misc/capValue';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextBehavior } from './ITextBehavior';\nimport type { TKeyMapIText } from './constants';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport { getDocumentFromElement } from '../../util/dom_misc';\nimport { CHANGED, LEFT, RIGHT } from '../../constants';\nimport type { IText } from './IText';\nimport type { TextStyleDeclaration } from '../Text/StyledText';\n\nexport abstract class ITextKeyBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextBehavior {\n /**\n * For functionalities on keyDown\n * Map a special key to a function of the instance/prototype\n * If you need different behavior for ESC or TAB or arrows, you have to change\n * this map setting the name of a function that you build on the IText or\n * your prototype.\n * the map change will affect all Instances unless you need for only some text Instances\n * in that case you have to clone this object and assign your Instance.\n * this.keysMap = Object.assign({}, this.keysMap);\n * The function must be in IText.prototype.myFunction And will receive event as args[0]\n */\n declare keysMap: TKeyMapIText;\n\n declare keysMapRtl: TKeyMapIText;\n\n /**\n * For functionalities on keyUp + ctrl || cmd\n */\n declare ctrlKeysMapUp: TKeyMapIText;\n\n /**\n * For functionalities on keyDown + ctrl || cmd\n */\n declare ctrlKeysMapDown: TKeyMapIText;\n\n declare hiddenTextarea: HTMLTextAreaElement | null;\n\n /**\n * DOM container to append the hiddenTextarea.\n * An alternative to attaching to the document.body.\n * Useful to reduce laggish redraw of the full document.body tree and\n * also with modals event capturing that won't let the textarea take focus.\n * @type HTMLElement\n * @default\n */\n declare hiddenTextareaContainer?: HTMLElement | null;\n\n private declare _clickHandlerInitialized: boolean;\n private declare _copyDone: boolean;\n private declare fromPaste: boolean;\n\n /**\n * Initializes hidden textarea (needed to bring up keyboard in iOS)\n */\n initHiddenTextarea() {\n const doc =\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument();\n const textarea = doc.createElement('textarea');\n Object.entries({\n autocapitalize: 'off',\n autocorrect: 'off',\n autocomplete: 'off',\n spellcheck: 'false',\n 'data-fabric': 'textarea',\n wrap: 'off',\n }).map(([attribute, value]) => textarea.setAttribute(attribute, value));\n const { top, left, fontSize } = this._calcTextareaPosition();\n // line-height: 1px; was removed from the style to fix this:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=870966\n textarea.style.cssText = `position: absolute; top: ${top}; left: ${left}; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ${fontSize};`;\n\n (this.hiddenTextareaContainer || doc.body).appendChild(textarea);\n\n Object.entries({\n blur: 'blur',\n keydown: 'onKeyDown',\n keyup: 'onKeyUp',\n input: 'onInput',\n copy: 'copy',\n cut: 'copy',\n paste: 'paste',\n compositionstart: 'onCompositionStart',\n compositionupdate: 'onCompositionUpdate',\n compositionend: 'onCompositionEnd',\n } as Record).map(([eventName, handler]) =>\n textarea.addEventListener(\n eventName,\n (this[handler] as EventListener).bind(this),\n ),\n );\n this.hiddenTextarea = textarea;\n }\n\n /**\n * Override this method to customize cursor behavior on textbox blur\n */\n blur() {\n this.abortCursorAnimation();\n }\n\n /**\n * Handles keydown event\n * only used for arrows and combination of modifier keys.\n * @param {KeyboardEvent} e Event object\n */\n onKeyDown(e: KeyboardEvent) {\n if (!this.isEditing) {\n return;\n }\n const keyMap = this.direction === 'rtl' ? this.keysMapRtl : this.keysMap;\n if (e.keyCode in keyMap) {\n (this[keyMap[e.keyCode] as keyof this] as (arg: KeyboardEvent) => void)(\n e,\n );\n } else if (e.keyCode in this.ctrlKeysMapDown && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapDown[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n if (e.keyCode >= 33 && e.keyCode <= 40) {\n // if i press an arrow key just update selection\n this.inCompositionMode = false;\n this.clearContextTop();\n this.renderCursorOrSelection();\n } else {\n this.canvas && this.canvas.requestRenderAll();\n }\n }\n\n /**\n * Handles keyup event\n * We handle KeyUp because ie11 and edge have difficulties copy/pasting\n * if a copy/cut event fired, keyup is dismissed\n * @param {KeyboardEvent} e Event object\n */\n onKeyUp(e: KeyboardEvent) {\n if (!this.isEditing || this._copyDone || this.inCompositionMode) {\n this._copyDone = false;\n return;\n }\n if (e.keyCode in this.ctrlKeysMapUp && (e.ctrlKey || e.metaKey)) {\n (\n this[this.ctrlKeysMapUp[e.keyCode] as keyof this] as (\n arg: KeyboardEvent,\n ) => void\n )(e);\n } else {\n return;\n }\n e.stopImmediatePropagation();\n e.preventDefault();\n this.canvas && this.canvas.requestRenderAll();\n }\n\n /**\n * Handles onInput event\n * @param {Event} e Event object\n */\n onInput(this: this & { hiddenTextarea: HTMLTextAreaElement }, e: Event) {\n const fromPaste = this.fromPaste;\n this.fromPaste = false;\n e && e.stopPropagation();\n if (!this.isEditing) {\n return;\n }\n const updateAndFire = () => {\n this.updateFromTextArea();\n this.fire(CHANGED);\n if (this.canvas) {\n this.canvas.fire('text:changed', { target: this as unknown as IText });\n this.canvas.requestRenderAll();\n }\n };\n if (this.hiddenTextarea.value === '') {\n this.styles = {};\n updateAndFire();\n return;\n }\n // decisions about style changes.\n const nextText = this._splitTextIntoLines(\n this.hiddenTextarea.value,\n ).graphemeText,\n charCount = this._text.length,\n nextCharCount = nextText.length,\n selectionStart = this.selectionStart,\n selectionEnd = this.selectionEnd,\n selection = selectionStart !== selectionEnd;\n let copiedStyle: TextStyleDeclaration[] | undefined,\n removedText,\n charDiff = nextCharCount - charCount,\n removeFrom,\n removeTo;\n\n const textareaSelection = this.fromStringToGraphemeSelection(\n this.hiddenTextarea.selectionStart,\n this.hiddenTextarea.selectionEnd,\n this.hiddenTextarea.value,\n );\n const backDelete = selectionStart > textareaSelection.selectionStart;\n\n if (selection) {\n removedText = this._text.slice(selectionStart, selectionEnd);\n charDiff += selectionEnd - selectionStart;\n } else if (nextCharCount < charCount) {\n if (backDelete) {\n removedText = this._text.slice(selectionEnd + charDiff, selectionEnd);\n } else {\n removedText = this._text.slice(\n selectionStart,\n selectionStart - charDiff,\n );\n }\n }\n const insertedText = nextText.slice(\n textareaSelection.selectionEnd - charDiff,\n textareaSelection.selectionEnd,\n );\n if (removedText && removedText.length) {\n if (insertedText.length) {\n // let's copy some style before deleting.\n // we want to copy the style before the cursor OR the style at the cursor if selection\n // is bigger than 0.\n copiedStyle = this.getSelectionStyles(\n selectionStart,\n selectionStart + 1,\n false,\n );\n // now duplicate the style one for each inserted text.\n copiedStyle = insertedText.map(\n () =>\n // this return an array of references, but that is fine since we are\n // copying the style later.\n copiedStyle![0],\n );\n }\n if (selection) {\n removeFrom = selectionStart;\n removeTo = selectionEnd;\n } else if (backDelete) {\n // detect differences between forwardDelete and backDelete\n removeFrom = selectionEnd - removedText.length;\n removeTo = selectionEnd;\n } else {\n removeFrom = selectionEnd;\n removeTo = selectionEnd + removedText.length;\n }\n this.removeStyleFromTo(removeFrom, removeTo);\n }\n if (insertedText.length) {\n const { copyPasteData } = getEnv();\n if (\n fromPaste &&\n insertedText.join('') === copyPasteData.copiedText &&\n !config.disableStyleCopyPaste\n ) {\n copiedStyle = copyPasteData.copiedTextStyle;\n }\n this.insertNewStyleBlock(insertedText, selectionStart, copiedStyle);\n }\n updateAndFire();\n }\n\n /**\n * Composition start\n */\n onCompositionStart() {\n this.inCompositionMode = true;\n }\n\n /**\n * Composition end\n */\n onCompositionEnd() {\n this.inCompositionMode = false;\n }\n\n onCompositionUpdate({ target }: CompositionEvent) {\n const { selectionStart, selectionEnd } = target as HTMLTextAreaElement;\n this.compositionStart = selectionStart;\n this.compositionEnd = selectionEnd;\n this.updateTextareaPosition();\n }\n\n /**\n * Copies selected text\n */\n copy() {\n if (this.selectionStart === this.selectionEnd) {\n //do not cut-copy if no selection\n return;\n }\n const { copyPasteData } = getEnv();\n copyPasteData.copiedText = this.getSelectedText();\n if (!config.disableStyleCopyPaste) {\n copyPasteData.copiedTextStyle = this.getSelectionStyles(\n this.selectionStart,\n this.selectionEnd,\n true,\n );\n } else {\n copyPasteData.copiedTextStyle = undefined;\n }\n this._copyDone = true;\n }\n\n /**\n * Pastes text\n */\n paste() {\n this.fromPaste = true;\n }\n\n /**\n * Finds the width in pixels before the cursor on the same line\n * @private\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {Number} widthBeforeCursor width before cursor\n */\n _getWidthBeforeCursor(lineIndex: number, charIndex: number): number {\n let widthBeforeCursor = this._getLineLeftOffset(lineIndex),\n bound;\n\n if (charIndex > 0) {\n bound = this.__charBounds[lineIndex][charIndex - 1];\n widthBeforeCursor += bound.left + bound.width;\n }\n return widthBeforeCursor;\n }\n\n /**\n * Gets start offset of a selection\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getDownCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n // if on last line, down cursor goes to end of line\n if (\n lineIndex === this._textLines.length - 1 ||\n e.metaKey ||\n e.keyCode === 34\n ) {\n // move to the end of a text\n return this._text.length - selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex + 1, widthBeforeCursor),\n textAfterCursor = this._textLines[lineIndex].slice(charIndex);\n return (\n textAfterCursor.length +\n indexOnOtherLine +\n 1 +\n this.missingNewlineOffset(lineIndex)\n );\n }\n\n /**\n * private\n * Helps finding if the offset should be counted from Start or End\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n _getSelectionForOffset(e: KeyboardEvent, isRight: boolean): number {\n if (e.shiftKey && this.selectionStart !== this.selectionEnd && isRight) {\n return this.selectionEnd;\n } else {\n return this.selectionStart;\n }\n }\n\n /**\n * @param {KeyboardEvent} e Event object\n * @param {Boolean} isRight\n * @return {Number}\n */\n getUpCursorOffset(e: KeyboardEvent, isRight: boolean): number {\n const selectionProp = this._getSelectionForOffset(e, isRight),\n cursorLocation = this.get2DCursorLocation(selectionProp),\n lineIndex = cursorLocation.lineIndex;\n if (lineIndex === 0 || e.metaKey || e.keyCode === 33) {\n // if on first line, up cursor goes to start of line\n return -selectionProp;\n }\n const charIndex = cursorLocation.charIndex,\n widthBeforeCursor = this._getWidthBeforeCursor(lineIndex, charIndex),\n indexOnOtherLine = this._getIndexOnLine(lineIndex - 1, widthBeforeCursor),\n textBeforeCursor = this._textLines[lineIndex].slice(0, charIndex),\n missingNewlineOffset = this.missingNewlineOffset(lineIndex - 1);\n // return a negative offset\n return (\n -this._textLines[lineIndex - 1].length +\n indexOnOtherLine -\n textBeforeCursor.length +\n (1 - missingNewlineOffset)\n );\n }\n\n /**\n * for a given width it founds the matching character.\n * @private\n */\n _getIndexOnLine(lineIndex: number, width: number) {\n const line = this._textLines[lineIndex],\n lineLeftOffset = this._getLineLeftOffset(lineIndex);\n let widthOfCharsOnLine = lineLeftOffset,\n indexOnLine = 0,\n charWidth,\n foundMatch;\n\n for (let j = 0, jlen = line.length; j < jlen; j++) {\n charWidth = this.__charBounds[lineIndex][j].width;\n widthOfCharsOnLine += charWidth;\n if (widthOfCharsOnLine > width) {\n foundMatch = true;\n const leftEdge = widthOfCharsOnLine - charWidth,\n rightEdge = widthOfCharsOnLine,\n offsetFromLeftEdge = Math.abs(leftEdge - width),\n offsetFromRightEdge = Math.abs(rightEdge - width);\n\n indexOnLine = offsetFromRightEdge < offsetFromLeftEdge ? j : j - 1;\n break;\n }\n }\n\n // reached end\n if (!foundMatch) {\n indexOnLine = line.length - 1;\n }\n\n return indexOnLine;\n }\n\n /**\n * Moves cursor down\n * @param {KeyboardEvent} e Event object\n */\n moveCursorDown(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorUpOrDown('Down', e);\n }\n\n /**\n * Moves cursor up\n * @param {KeyboardEvent} e Event object\n */\n moveCursorUp(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorUpOrDown('Up', e);\n }\n\n /**\n * Moves cursor up or down, fires the events\n * @param {String} direction 'Up' or 'Down'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorUpOrDown(direction: 'Up' | 'Down', e: KeyboardEvent) {\n const offset = this[`get${direction}CursorOffset`](\n e,\n this._selectionDirection === RIGHT,\n );\n if (e.shiftKey) {\n this.moveCursorWithShift(offset);\n } else {\n this.moveCursorWithoutShift(offset);\n }\n if (offset !== 0) {\n const max = this.text.length;\n this.selectionStart = capValue(0, this.selectionStart, max);\n this.selectionEnd = capValue(0, this.selectionEnd, max);\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor with shift\n * @param {Number} offset\n */\n moveCursorWithShift(offset: number) {\n const newSelection =\n this._selectionDirection === LEFT\n ? this.selectionStart + offset\n : this.selectionEnd + offset;\n this.setSelectionStartEndWithShift(\n this.selectionStart,\n this.selectionEnd,\n newSelection,\n );\n return offset !== 0;\n }\n\n /**\n * Moves cursor up without shift\n * @param {Number} offset\n */\n moveCursorWithoutShift(offset: number) {\n if (offset < 0) {\n this.selectionStart += offset;\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionEnd += offset;\n this.selectionStart = this.selectionEnd;\n }\n return offset !== 0;\n }\n\n /**\n * Moves cursor left\n * @param {KeyboardEvent} e Event object\n */\n moveCursorLeft(e: KeyboardEvent) {\n if (this.selectionStart === 0 && this.selectionEnd === 0) {\n return;\n }\n this._moveCursorLeftOrRight('Left', e);\n }\n\n /**\n * @private\n * @return {Boolean} true if a change happened\n *\n * @todo refactor not to use method name composition\n */\n _move(\n e: KeyboardEvent,\n prop: 'selectionStart' | 'selectionEnd',\n direction: 'Left' | 'Right',\n ): boolean {\n let newValue: number | undefined;\n if (e.altKey) {\n newValue = this[`findWordBoundary${direction}`](this[prop]);\n } else if (e.metaKey || e.keyCode === 35 || e.keyCode === 36) {\n newValue = this[`findLineBoundary${direction}`](this[prop]);\n } else {\n this[prop] += direction === 'Left' ? -1 : 1;\n return true;\n }\n if (typeof newValue !== 'undefined' && this[prop] !== newValue) {\n this[prop] = newValue;\n return true;\n }\n return false;\n }\n\n /**\n * @private\n */\n _moveLeft(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Left');\n }\n\n /**\n * @private\n */\n _moveRight(e: KeyboardEvent, prop: 'selectionStart' | 'selectionEnd') {\n return this._move(e, prop, 'Right');\n }\n\n /**\n * Moves cursor left without keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithoutShift(e: KeyboardEvent) {\n let change = true;\n this._selectionDirection = LEFT;\n\n // only move cursor when there is no selection,\n // otherwise we discard it, and leave cursor on same place\n if (\n this.selectionEnd === this.selectionStart &&\n this.selectionStart !== 0\n ) {\n change = this._moveLeft(e, 'selectionStart');\n }\n this.selectionEnd = this.selectionStart;\n return change;\n }\n\n /**\n * Moves cursor left while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorLeftWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === RIGHT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveLeft(e, 'selectionEnd');\n } else if (this.selectionStart !== 0) {\n this._selectionDirection = LEFT;\n return this._moveLeft(e, 'selectionStart');\n }\n }\n\n /**\n * Moves cursor right\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRight(e: KeyboardEvent) {\n if (\n this.selectionStart >= this._text.length &&\n this.selectionEnd >= this._text.length\n ) {\n return;\n }\n this._moveCursorLeftOrRight('Right', e);\n }\n\n /**\n * Moves cursor right or Left, fires event\n * @param {String} direction 'Left', 'Right'\n * @param {KeyboardEvent} e Event object\n */\n _moveCursorLeftOrRight(direction: 'Left' | 'Right', e: KeyboardEvent) {\n const actionName = `moveCursor${direction}${\n e.shiftKey ? 'WithShift' : 'WithoutShift'\n }` as const;\n this._currentCursorOpacity = 1;\n if (this[actionName](e)) {\n // TODO fix: abort and init should be an alternative depending\n // on selectionStart/End being equal or different\n this.abortCursorAnimation();\n this.initDelayedCursor();\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Moves cursor right while keeping selection\n * @param {KeyboardEvent} e\n */\n moveCursorRightWithShift(e: KeyboardEvent) {\n if (\n this._selectionDirection === LEFT &&\n this.selectionStart !== this.selectionEnd\n ) {\n return this._moveRight(e, 'selectionStart');\n } else if (this.selectionEnd !== this._text.length) {\n this._selectionDirection = RIGHT;\n return this._moveRight(e, 'selectionEnd');\n }\n }\n\n /**\n * Moves cursor right without keeping selection\n * @param {KeyboardEvent} e Event object\n */\n moveCursorRightWithoutShift(e: KeyboardEvent) {\n let changed = true;\n this._selectionDirection = RIGHT;\n\n if (this.selectionStart === this.selectionEnd) {\n changed = this._moveRight(e, 'selectionStart');\n this.selectionEnd = this.selectionStart;\n } else {\n this.selectionStart = this.selectionEnd;\n }\n return changed;\n }\n}\n","import type { TPointerEvent, TPointerEventInfo } from '../../EventTypeDefs';\nimport type { XY } from '../../Point';\nimport { Point } from '../../Point';\nimport { stopEvent } from '../../util/dom_event';\nimport { invertTransform } from '../../util/misc/matrix';\nimport { DraggableTextDelegate } from './DraggableTextDelegate';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextKeyBehavior } from './ITextKeyBehavior';\nimport type { TOptions } from '../../typedefs';\nimport type { TextProps, SerializedTextProps } from '../Text/Text';\nimport type { IText } from './IText';\n/**\n * `LEFT_CLICK === 0`\n */\nconst notALeftClick = (e: Event) => !!(e as MouseEvent).button;\n\nexport abstract class ITextClickBehavior<\n Props extends TOptions = Partial,\n SProps extends SerializedTextProps = SerializedTextProps,\n EventSpec extends ITextEvents = ITextEvents,\n> extends ITextKeyBehavior {\n private declare __lastSelected: boolean;\n private declare __lastClickTime: number;\n private declare __lastLastClickTime: number;\n private declare __lastPointer: XY | Record;\n private declare __newClickTime: number;\n\n protected draggableTextDelegate: DraggableTextDelegate;\n\n initBehavior() {\n // Initializes event handlers related to cursor or selection\n this.on('mousedown', this._mouseDownHandler);\n this.on('mousedown:before', this._mouseDownHandlerBefore);\n this.on('mouseup', this.mouseUpHandler);\n this.on('mousedblclick', this.doubleClickHandler);\n this.on('tripleclick', this.tripleClickHandler);\n\n // Initializes \"dbclick\" event handler\n this.__lastClickTime = +new Date();\n // for triple click\n this.__lastLastClickTime = +new Date();\n this.__lastPointer = {};\n this.on('mousedown', this.onMouseDown);\n\n this.draggableTextDelegate = new DraggableTextDelegate(\n this as unknown as IText,\n );\n\n super.initBehavior();\n }\n\n /**\n * If this method returns true a mouse move operation over a text selection\n * will not prevent the native mouse event allowing the browser to start a drag operation.\n * shouldStartDragging can be read 'do not prevent default for mouse move event'\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns\n */\n shouldStartDragging() {\n return this.draggableTextDelegate.isActive();\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drag source,\n * @see also {@link DraggableTextDelegate#isActive}\n * To prevent drag and drop between objects both shouldStartDragging and onDragStart should return false\n * @returns {boolean} should handle event\n */\n onDragStart(e: DragEvent) {\n return this.draggableTextDelegate.onDragStart(e);\n }\n\n /**\n * @public override this method to control whether instance should/shouldn't become a drop target\n */\n canDrop(e: DragEvent) {\n return this.draggableTextDelegate.canDrop(e);\n }\n\n /**\n * Default event handler to simulate triple click\n * @private\n */\n onMouseDown(options: TPointerEventInfo) {\n if (!this.canvas) {\n return;\n }\n this.__newClickTime = +new Date();\n const newPointer = options.pointer;\n if (this.isTripleClick(newPointer)) {\n this.fire('tripleclick', options);\n stopEvent(options.e);\n }\n this.__lastLastClickTime = this.__lastClickTime;\n this.__lastClickTime = this.__newClickTime;\n this.__lastPointer = newPointer;\n this.__lastSelected = this.selected && !this.getActiveControl();\n }\n\n isTripleClick(newPointer: XY) {\n return (\n this.__newClickTime - this.__lastClickTime < 500 &&\n this.__lastClickTime - this.__lastLastClickTime < 500 &&\n this.__lastPointer.x === newPointer.x &&\n this.__lastPointer.y === newPointer.y\n );\n }\n\n /**\n * Default handler for double click, select a word\n */\n doubleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectWord(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default handler for triple click, select a line\n */\n tripleClickHandler(options: TPointerEventInfo) {\n if (!this.isEditing) {\n return;\n }\n this.selectLine(this.getSelectionStartFromPointer(options.e));\n }\n\n /**\n * Default event handler for the basic functionalities needed on _mouseDown\n * can be overridden to do something different.\n * Scope of this implementation is: find the click position, set selectionStart\n * find selectionEnd, initialize the drawing of either cursor or selection area\n * initializing a mousedDown on a text area will cancel fabricjs knowledge of\n * current compositionMode. It will be set to false.\n */\n _mouseDownHandler({ e }: TPointerEventInfo) {\n if (\n !this.canvas ||\n !this.editable ||\n notALeftClick(e) ||\n this.getActiveControl()\n ) {\n return;\n }\n\n if (this.draggableTextDelegate.start(e)) {\n return;\n }\n\n this.canvas.textEditingManager.register(this);\n\n if (this.selected) {\n this.inCompositionMode = false;\n this.setCursorByClick(e);\n }\n\n if (this.isEditing) {\n this.__selectionStartOnMouseDown = this.selectionStart;\n if (this.selectionStart === this.selectionEnd) {\n this.abortCursorAnimation();\n }\n this.renderCursorOrSelection();\n }\n }\n\n /**\n * Default event handler for the basic functionalities needed on mousedown:before\n * can be overridden to do something different.\n * Scope of this implementation is: verify the object is already selected when mousing down\n */\n _mouseDownHandlerBefore({ e }: TPointerEventInfo) {\n if (!this.canvas || !this.editable || notALeftClick(e)) {\n return;\n }\n // we want to avoid that an object that was selected and then becomes unselectable,\n // may trigger editing mode in some way.\n this.selected = this === this.canvas._activeObject;\n }\n\n /**\n * standard handler for mouse up, overridable\n * @private\n */\n mouseUpHandler({ e, transform }: TPointerEventInfo) {\n const didDrag = this.draggableTextDelegate.end(e);\n if (this.canvas) {\n this.canvas.textEditingManager.unregister(this);\n\n const activeObject = this.canvas._activeObject;\n if (activeObject && activeObject !== this) {\n // avoid running this logic when there is an active object\n // this because is possible with shift click and fast clicks,\n // to rapidly deselect and reselect this object and trigger an enterEdit\n return;\n }\n }\n if (\n !this.editable ||\n (this.group && !this.group.interactive) ||\n (transform && transform.actionPerformed) ||\n notALeftClick(e) ||\n didDrag\n ) {\n return;\n }\n\n if (this.__lastSelected && !this.getActiveControl()) {\n this.selected = false;\n this.__lastSelected = false;\n this.enterEditing(e);\n if (this.selectionStart === this.selectionEnd) {\n this.initDelayedCursor(true);\n } else {\n this.renderCursorOrSelection();\n }\n } else {\n this.selected = true;\n }\n }\n\n /**\n * Changes cursor location in a text depending on passed pointer (x/y) object\n * @param {TPointerEvent} e Event object\n */\n setCursorByClick(e: TPointerEvent) {\n const newSelection = this.getSelectionStartFromPointer(e),\n start = this.selectionStart,\n end = this.selectionEnd;\n if (e.shiftKey) {\n this.setSelectionStartEndWithShift(start, end, newSelection);\n } else {\n this.selectionStart = newSelection;\n this.selectionEnd = newSelection;\n }\n if (this.isEditing) {\n this._fireSelectionChanged();\n this._updateTextarea();\n }\n }\n\n /**\n * Returns index of a character corresponding to where an object was clicked\n * @param {TPointerEvent} e Event object\n * @return {Number} Index of a character\n */\n getSelectionStartFromPointer(e: TPointerEvent): number {\n const mouseOffset = this.canvas!.getScenePoint(e)\n .transform(invertTransform(this.calcTransformMatrix()))\n .add(new Point(-this._getLeftOffset(), -this._getTopOffset()));\n let height = 0,\n charIndex = 0,\n lineIndex = 0;\n\n for (let i = 0; i < this._textLines.length; i++) {\n if (height <= mouseOffset.y) {\n height += this.getHeightOfLine(i);\n lineIndex = i;\n if (i > 0) {\n charIndex +=\n this._textLines[i - 1].length + this.missingNewlineOffset(i - 1);\n }\n } else {\n break;\n }\n }\n const lineLeftOffset = Math.abs(this._getLineLeftOffset(lineIndex));\n let width = lineLeftOffset;\n const charLength = this._textLines[lineIndex].length;\n const chars = this.__charBounds[lineIndex];\n for (let j = 0; j < charLength; j++) {\n // i removed something about flipX here, check.\n const charWidth = chars[j].kernedWidth;\n const widthAfter = width + charWidth;\n if (mouseOffset.x <= widthAfter) {\n // if the pointer is closer to the end of the char we increment charIndex\n // in order to position the cursor after the char\n if (\n Math.abs(mouseOffset.x - widthAfter) <=\n Math.abs(mouseOffset.x - width)\n ) {\n charIndex++;\n }\n break;\n }\n width = widthAfter;\n charIndex++;\n }\n\n return Math.min(\n // if object is horizontally flipped, mirror cursor location from the end\n this.flipX ? charLength - charIndex : charIndex,\n this._text.length,\n );\n }\n}\n","export type TKeyMapIText = Record<\n KeyboardEvent['keyCode'],\n CursorHandlingMethods\n>;\n\nexport type CursorHandlingMethods =\n | 'moveCursorUp'\n | 'moveCursorDown'\n | 'moveCursorLeft'\n | 'moveCursorRight'\n | 'exitEditing'\n | 'copy'\n | 'cut'\n | 'selectAll';\n\nconst MOVE_CURSOR_UP: CursorHandlingMethods = 'moveCursorUp';\nconst MOVE_CURSOR_DOWN: CursorHandlingMethods = 'moveCursorDown';\nconst MOVE_CURSOR_LEFT: CursorHandlingMethods = 'moveCursorLeft';\nconst MOVE_CURSOR_RIGHT: CursorHandlingMethods = 'moveCursorRight';\nconst EXIT_EDITING: CursorHandlingMethods = 'exitEditing';\n\n// @TODO look into import { Key } from 'ts-key-enum';\n// and transition from keyCode to Key\n// also reduce string duplication\nexport const keysMap: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_RIGHT,\n 36: MOVE_CURSOR_LEFT,\n 37: MOVE_CURSOR_LEFT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_RIGHT,\n 40: MOVE_CURSOR_DOWN,\n};\n\nexport const keysMapRtl: TKeyMapIText = {\n 9: EXIT_EDITING,\n 27: EXIT_EDITING,\n 33: MOVE_CURSOR_UP,\n 34: MOVE_CURSOR_DOWN,\n 35: MOVE_CURSOR_LEFT,\n 36: MOVE_CURSOR_RIGHT,\n 37: MOVE_CURSOR_RIGHT,\n 38: MOVE_CURSOR_UP,\n 39: MOVE_CURSOR_LEFT,\n 40: MOVE_CURSOR_DOWN,\n};\n\n/**\n * For functionalities on keyUp + ctrl || cmd\n */\nexport const ctrlKeysMapUp: TKeyMapIText = {\n 67: 'copy',\n // there was a reason this wasn't deleted. for now leave it here\n 88: 'cut',\n};\n\n/**\n * For functionalities on keyDown + ctrl || cmd\n */\nexport const ctrlKeysMapDown: TKeyMapIText = {\n 65: 'selectAll',\n};\n","import { Canvas } from '../../canvas/Canvas';\nimport type { ITextEvents } from './ITextBehavior';\nimport { ITextClickBehavior } from './ITextClickBehavior';\nimport {\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n keysMap,\n keysMapRtl,\n} from './constants';\nimport type { TClassProperties, TFiller, TOptions } from '../../typedefs';\nimport { classRegistry } from '../../ClassRegistry';\nimport type { SerializedTextProps, TextProps } from '../Text/Text';\nimport {\n JUSTIFY,\n JUSTIFY_CENTER,\n JUSTIFY_LEFT,\n JUSTIFY_RIGHT,\n} from '../Text/constants';\nimport { CENTER, FILL, LEFT, RIGHT } from '../../constants';\nimport type { ObjectToCanvasElementOptions } from '../Object/Object';\n\nexport type CursorBoundaries = {\n left: number;\n top: number;\n leftOffset: number;\n topOffset: number;\n};\n\nexport type CursorRenderingData = {\n color: string;\n opacity: number;\n left: number;\n top: number;\n width: number;\n height: number;\n};\n\n// Declare IText protected properties to workaround TS\nconst protectedDefaultValues = {\n _selectionDirection: null,\n _reSpace: /\\s|\\r?\\n/,\n inCompositionMode: false,\n};\n\nexport const iTextDefaultValues: Partial> = {\n selectionStart: 0,\n selectionEnd: 0,\n selectionColor: 'rgba(17,119,255,0.3)',\n isEditing: false,\n editable: true,\n editingBorderColor: 'rgba(102,153,255,0.25)',\n cursorWidth: 2,\n cursorColor: '',\n cursorDelay: 1000,\n cursorDuration: 600,\n caching: true,\n hiddenTextareaContainer: null,\n keysMap,\n keysMapRtl,\n ctrlKeysMapDown,\n ctrlKeysMapUp,\n ...protectedDefaultValues,\n};\n\n// @TODO this is not complete\ninterface UniqueITextProps {\n selectionStart: number;\n selectionEnd: number;\n}\n\nexport interface SerializedITextProps\n extends SerializedTextProps,\n UniqueITextProps {}\n\nexport interface ITextProps extends TextProps, UniqueITextProps {}\n\n/**\n * @fires changed\n * @fires selection:changed\n * @fires editing:entered\n * @fires editing:exited\n * @fires dragstart\n * @fires drag drag event firing on the drag source\n * @fires dragend\n * @fires copy\n * @fires cut\n * @fires paste\n *\n * #### Supported key combinations\n * ```\n * Move cursor: left, right, up, down\n * Select character: shift + left, shift + right\n * Select text vertically: shift + up, shift + down\n * Move cursor by word: alt + left, alt + right\n * Select words: shift + alt + left, shift + alt + right\n * Move cursor to line start/end: cmd + left, cmd + right or home, end\n * Select till start/end of line: cmd + shift + left, cmd + shift + right or shift + home, shift + end\n * Jump to start/end of text: cmd + up, cmd + down\n * Select till start/end of text: cmd + shift + up, cmd + shift + down or shift + pgUp, shift + pgDown\n * Delete character: backspace\n * Delete word: alt + backspace\n * Delete line: cmd + backspace\n * Forward delete: delete\n * Copy text: ctrl/cmd + c\n * Paste text: ctrl/cmd + v\n * Cut text: ctrl/cmd + x\n * Select entire text: ctrl/cmd + a\n * Quit editing tab or esc\n * ```\n *\n * #### Supported mouse/touch combination\n * ```\n * Position cursor: click/touch\n * Create selection: click/touch & drag\n * Create selection: click & shift + click\n * Select word: double click\n * Select line: triple click\n * ```\n */\nexport class IText<\n Props extends TOptions = Partial,\n SProps extends SerializedITextProps = SerializedITextProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends ITextClickBehavior\n implements UniqueITextProps\n{\n /**\n * Index where text selection starts (or where cursor is when there is no selection)\n * @type Number\n * @default\n */\n declare selectionStart: number;\n\n /**\n * Index where text selection ends\n * @type Number\n * @default\n */\n declare selectionEnd: number;\n\n declare compositionStart: number;\n\n declare compositionEnd: number;\n\n /**\n * Color of text selection\n * @type String\n * @default\n */\n declare selectionColor: string;\n\n /**\n * Indicates whether text is in editing mode\n * @type Boolean\n * @default\n */\n declare isEditing: boolean;\n\n /**\n * Indicates whether a text can be edited\n * @type Boolean\n * @default\n */\n declare editable: boolean;\n\n /**\n * Border color of text object while it's in editing mode\n * @type String\n * @default\n */\n declare editingBorderColor: string;\n\n /**\n * Width of cursor (in px)\n * @type Number\n * @default\n */\n declare cursorWidth: number;\n\n /**\n * Color of text cursor color in editing mode.\n * if not set (default) will take color from the text.\n * if set to a color value that fabric can understand, it will\n * be used instead of the color of the text at the current position.\n * @type String\n * @default\n */\n declare cursorColor: string;\n\n /**\n * Delay between cursor blink (in ms)\n * @type Number\n * @default\n */\n declare cursorDelay: number;\n\n /**\n * Duration of cursor fade in (in ms)\n * @type Number\n * @default\n */\n declare cursorDuration: number;\n\n declare compositionColor: string;\n\n /**\n * Indicates whether internal text char widths can be cached\n * @type Boolean\n * @default\n */\n declare caching: boolean;\n\n static ownDefaults = iTextDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...IText.ownDefaults };\n }\n\n static type = 'IText';\n\n get type() {\n const type = super.type;\n // backward compatibility\n return type === 'itext' ? 'i-text' : type;\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...IText.ownDefaults, ...options } as Props);\n this.initBehavior();\n }\n\n /**\n * While editing handle differently\n * @private\n * @param {string} key\n * @param {*} value\n */\n _set(key: string, value: any) {\n if (this.isEditing && this._savedProps && key in this._savedProps) {\n // @ts-expect-error irritating TS\n this._savedProps[key] = value;\n return this;\n }\n if (key === 'canvas') {\n this.canvas instanceof Canvas &&\n this.canvas.textEditingManager.remove(this);\n value instanceof Canvas && value.textEditingManager.add(this);\n }\n return super._set(key, value);\n }\n\n /**\n * Sets selection start (left boundary of a selection)\n * @param {Number} index Index to set selection start to\n */\n setSelectionStart(index: number) {\n index = Math.max(index, 0);\n this._updateAndFire('selectionStart', index);\n }\n\n /**\n * Sets selection end (right boundary of a selection)\n * @param {Number} index Index to set selection end to\n */\n setSelectionEnd(index: number) {\n index = Math.min(index, this.text.length);\n this._updateAndFire('selectionEnd', index);\n }\n\n /**\n * @private\n * @param {String} property 'selectionStart' or 'selectionEnd'\n * @param {Number} index new position of property\n */\n protected _updateAndFire(\n property: 'selectionStart' | 'selectionEnd',\n index: number,\n ) {\n if (this[property] !== index) {\n this._fireSelectionChanged();\n this[property] = index;\n }\n this._updateTextarea();\n }\n\n /**\n * Fires the even of selection changed\n * @private\n */\n _fireSelectionChanged() {\n this.fire('selection:changed');\n this.canvas && this.canvas.fire('text:selection:changed', { target: this });\n }\n\n /**\n * Initialize text dimensions. Render all text on given context\n * or on a offscreen canvas to get the text width with measureText.\n * Updates this.width and this.height with the proper values.\n * Does not return dimensions.\n * @private\n */\n initDimensions() {\n this.isEditing && this.initDelayedCursor();\n super.initDimensions();\n }\n\n /**\n * Gets style of a current selection/cursor (at the start position)\n * if startIndex or endIndex are not provided, selectionStart or selectionEnd will be used.\n * @param {Number} startIndex Start index to get styles at\n * @param {Number} endIndex End index to get styles at, if not specified selectionEnd or startIndex + 1\n * @param {Boolean} [complete] get full style or not\n * @return {Array} styles an array with one, zero or more Style objects\n */\n getSelectionStyles(\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n complete?: boolean,\n ) {\n return super.getSelectionStyles(startIndex, endIndex, complete);\n }\n\n /**\n * Sets style of a current selection, if no selection exist, do not set anything.\n * @param {Object} [styles] Styles object\n * @param {Number} [startIndex] Start index to get styles at\n * @param {Number} [endIndex] End index to get styles at, if not specified selectionEnd or startIndex + 1\n */\n setSelectionStyles(\n styles: object,\n startIndex: number = this.selectionStart || 0,\n endIndex: number = this.selectionEnd,\n ) {\n return super.setSelectionStyles(styles, startIndex, endIndex);\n }\n\n /**\n * Returns 2d representation (lineIndex and charIndex) of cursor (or selection start)\n * @param {Number} [selectionStart] Optional index. When not given, current selectionStart is used.\n * @param {Boolean} [skipWrapping] consider the location for unwrapped lines. useful to manage styles.\n */\n get2DCursorLocation(\n selectionStart = this.selectionStart,\n skipWrapping?: boolean,\n ) {\n return super.get2DCursorLocation(selectionStart, skipWrapping);\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n render(ctx: CanvasRenderingContext2D) {\n super.render(ctx);\n // clear the cursorOffsetCache, so we ensure to calculate once per renderCursor\n // the correct position but not at every cursor animation.\n this.cursorOffsetCache = {};\n this.renderCursorOrSelection();\n }\n\n /**\n * @override block cursor/selection logic while rendering the exported canvas\n * @todo this workaround should be replaced with a more robust solution\n */\n toCanvasElement(options?: ObjectToCanvasElementOptions): HTMLCanvasElement {\n const isEditing = this.isEditing;\n this.isEditing = false;\n const canvas = super.toCanvasElement(options);\n this.isEditing = isEditing;\n return canvas;\n }\n\n /**\n * Renders cursor or selection (depending on what exists)\n * it does on the contextTop. If contextTop is not available, do nothing.\n */\n renderCursorOrSelection() {\n if (!this.isEditing) {\n return;\n }\n const ctx = this.clearContextTop(true);\n if (!ctx) {\n return;\n }\n const boundaries = this._getCursorBoundaries();\n if (this.selectionStart === this.selectionEnd && !this.inCompositionMode) {\n this.renderCursor(ctx, boundaries);\n } else {\n this.renderSelection(ctx, boundaries);\n }\n this.canvas!.contextTopDirty = true;\n ctx.restore();\n }\n\n /**\n * Returns cursor boundaries (left, top, leftOffset, topOffset)\n * left/top are left/top of entire text box\n * leftOffset/topOffset are offset from that left/top point of a text box\n * @private\n * @param {number} [index] index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundaries(\n index: number = this.selectionStart,\n skipCaching?: boolean,\n ): CursorBoundaries {\n const left = this._getLeftOffset(),\n top = this._getTopOffset(),\n offsets = this._getCursorBoundariesOffsets(index, skipCaching);\n return {\n left: left,\n top: top,\n leftOffset: offsets.left,\n topOffset: offsets.top,\n };\n }\n\n /**\n * Caches and returns cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n * @param {boolean} [skipCaching]\n */\n _getCursorBoundariesOffsets(\n index: number,\n skipCaching?: boolean,\n ): { left: number; top: number } {\n if (skipCaching) {\n return this.__getCursorBoundariesOffsets(index);\n }\n if (this.cursorOffsetCache && 'top' in this.cursorOffsetCache) {\n return this.cursorOffsetCache as { left: number; top: number };\n }\n return (this.cursorOffsetCache = this.__getCursorBoundariesOffsets(index));\n }\n\n /**\n * Calculates cursor left/top offset relative to instance's center point\n * @private\n * @param {number} index index from start\n */\n __getCursorBoundariesOffsets(index: number) {\n let topOffset = 0,\n leftOffset = 0;\n const { charIndex, lineIndex } = this.get2DCursorLocation(index);\n\n for (let i = 0; i < lineIndex; i++) {\n topOffset += this.getHeightOfLine(i);\n }\n const lineLeftOffset = this._getLineLeftOffset(lineIndex);\n const bound = this.__charBounds[lineIndex][charIndex];\n bound && (leftOffset = bound.left);\n if (\n this.charSpacing !== 0 &&\n charIndex === this._textLines[lineIndex].length\n ) {\n leftOffset -= this._getWidthOfCharSpacing();\n }\n const boundaries = {\n top: topOffset,\n left: lineLeftOffset + (leftOffset > 0 ? leftOffset : 0),\n };\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n boundaries.left *= -1;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n boundaries.left = lineLeftOffset - (leftOffset > 0 ? leftOffset : 0);\n }\n }\n return boundaries;\n }\n\n /**\n * Renders cursor on context Top, outside the animation cycle, on request\n * Used for the drag/drop effect.\n * If contextTop is not available, do nothing.\n */\n renderCursorAt(selectionStart: number) {\n this._renderCursor(\n this.canvas!.contextTop,\n this._getCursorBoundaries(selectionStart, true),\n selectionStart,\n );\n }\n\n /**\n * Renders cursor\n * @param {Object} boundaries\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderCursor(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n this._renderCursor(ctx, boundaries, this.selectionStart);\n }\n\n /**\n * Return the data needed to render the cursor for given selection start\n * The left,top are relative to the object, while width and height are prescaled\n * to look think with canvas zoom and object scaling,\n * so they depend on canvas and object scaling\n */\n getCursorRenderingData(\n selectionStart: number = this.selectionStart,\n boundaries: CursorBoundaries = this._getCursorBoundaries(selectionStart),\n ): CursorRenderingData {\n const cursorLocation = this.get2DCursorLocation(selectionStart),\n lineIndex = cursorLocation.lineIndex,\n charIndex =\n cursorLocation.charIndex > 0 ? cursorLocation.charIndex - 1 : 0,\n charHeight = this.getValueOfPropertyAt(lineIndex, charIndex, 'fontSize'),\n multiplier = this.getObjectScaling().x * this.canvas!.getZoom(),\n cursorWidth = this.cursorWidth / multiplier,\n dy = this.getValueOfPropertyAt(lineIndex, charIndex, 'deltaY'),\n topOffset =\n boundaries.topOffset +\n ((1 - this._fontSizeFraction) * this.getHeightOfLine(lineIndex)) /\n this.lineHeight -\n charHeight * (1 - this._fontSizeFraction);\n\n return {\n color:\n this.cursorColor ||\n (this.getValueOfPropertyAt(lineIndex, charIndex, 'fill') as string),\n opacity: this._currentCursorOpacity,\n left: boundaries.left + boundaries.leftOffset - cursorWidth / 2,\n top: topOffset + boundaries.top + dy,\n width: cursorWidth,\n height: charHeight,\n };\n }\n\n /**\n * Render the cursor at the given selectionStart.\n *\n */\n _renderCursor(\n ctx: CanvasRenderingContext2D,\n boundaries: CursorBoundaries,\n selectionStart: number,\n ) {\n const { color, opacity, left, top, width, height } =\n this.getCursorRenderingData(selectionStart, boundaries);\n ctx.fillStyle = color;\n ctx.globalAlpha = opacity;\n ctx.fillRect(left, top, width, height);\n }\n\n /**\n * Renders text selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n renderSelection(ctx: CanvasRenderingContext2D, boundaries: CursorBoundaries) {\n const selection = {\n selectionStart: this.inCompositionMode\n ? this.hiddenTextarea!.selectionStart\n : this.selectionStart,\n selectionEnd: this.inCompositionMode\n ? this.hiddenTextarea!.selectionEnd\n : this.selectionEnd,\n };\n this._renderSelection(ctx, selection, boundaries);\n }\n\n /**\n * Renders drag start text selection\n */\n renderDragSourceEffect() {\n const dragStartSelection =\n this.draggableTextDelegate.getDragStartSelection()!;\n this._renderSelection(\n this.canvas!.contextTop,\n dragStartSelection,\n this._getCursorBoundaries(dragStartSelection.selectionStart, true),\n );\n }\n\n renderDropTargetEffect(e: DragEvent) {\n const dragSelection = this.getSelectionStartFromPointer(e);\n this.renderCursorAt(dragSelection);\n }\n\n /**\n * Renders text selection\n * @private\n * @param {{ selectionStart: number, selectionEnd: number }} selection\n * @param {Object} boundaries Object with left/top/leftOffset/topOffset\n * @param {CanvasRenderingContext2D} ctx transformed context to draw on\n */\n _renderSelection(\n ctx: CanvasRenderingContext2D,\n selection: { selectionStart: number; selectionEnd: number },\n boundaries: CursorBoundaries,\n ) {\n const selectionStart = selection.selectionStart,\n selectionEnd = selection.selectionEnd,\n isJustify = this.textAlign.includes(JUSTIFY),\n start = this.get2DCursorLocation(selectionStart),\n end = this.get2DCursorLocation(selectionEnd),\n startLine = start.lineIndex,\n endLine = end.lineIndex,\n startChar = start.charIndex < 0 ? 0 : start.charIndex,\n endChar = end.charIndex < 0 ? 0 : end.charIndex;\n\n for (let i = startLine; i <= endLine; i++) {\n const lineOffset = this._getLineLeftOffset(i) || 0;\n let lineHeight = this.getHeightOfLine(i),\n realLineHeight = 0,\n boxStart = 0,\n boxEnd = 0;\n\n if (i === startLine) {\n boxStart = this.__charBounds[startLine][startChar].left;\n }\n if (i >= startLine && i < endLine) {\n boxEnd =\n isJustify && !this.isEndOfWrapping(i)\n ? this.width\n : this.getLineWidth(i) || 5; // WTF is this 5?\n } else if (i === endLine) {\n if (endChar === 0) {\n boxEnd = this.__charBounds[endLine][endChar].left;\n } else {\n const charSpacing = this._getWidthOfCharSpacing();\n boxEnd =\n this.__charBounds[endLine][endChar - 1].left +\n this.__charBounds[endLine][endChar - 1].width -\n charSpacing;\n }\n }\n realLineHeight = lineHeight;\n if (this.lineHeight < 1 || (i === endLine && this.lineHeight > 1)) {\n lineHeight /= this.lineHeight;\n }\n let drawStart = boundaries.left + lineOffset + boxStart,\n drawHeight = lineHeight,\n extraTop = 0;\n const drawWidth = boxEnd - boxStart;\n if (this.inCompositionMode) {\n ctx.fillStyle = this.compositionColor || 'black';\n drawHeight = 1;\n extraTop = lineHeight;\n } else {\n ctx.fillStyle = this.selectionColor;\n }\n if (this.direction === 'rtl') {\n if (\n this.textAlign === RIGHT ||\n this.textAlign === JUSTIFY ||\n this.textAlign === JUSTIFY_RIGHT\n ) {\n drawStart = this.width - drawStart - drawWidth;\n } else if (this.textAlign === LEFT || this.textAlign === JUSTIFY_LEFT) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n } else if (\n this.textAlign === CENTER ||\n this.textAlign === JUSTIFY_CENTER\n ) {\n drawStart = boundaries.left + lineOffset - boxEnd;\n }\n }\n ctx.fillRect(\n drawStart,\n boundaries.top + boundaries.topOffset + extraTop,\n drawWidth,\n drawHeight,\n );\n boundaries.topOffset += realLineHeight;\n }\n }\n\n /**\n * High level function to know the height of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns fontSize of char at the current cursor\n * Unused from the library, is for the end user\n * @return {Number} Character font size\n */\n getCurrentCharFontSize(): number {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, 'fontSize');\n }\n\n /**\n * High level function to know the color of the cursor.\n * the currentChar is the one that precedes the cursor\n * Returns color (fill) of char at the current cursor\n * if the text object has a pattern or gradient for filler, it will return that.\n * Unused by the library, is for the end user\n * @return {String | TFiller} Character color (fill)\n */\n getCurrentCharColor(): string | TFiller | null {\n const cp = this._getCurrentCharIndex();\n return this.getValueOfPropertyAt(cp.l, cp.c, FILL);\n }\n\n /**\n * Returns the cursor position for the getCurrent.. functions\n * @private\n */\n _getCurrentCharIndex() {\n const cursorPosition = this.get2DCursorLocation(this.selectionStart, true),\n charIndex =\n cursorPosition.charIndex > 0 ? cursorPosition.charIndex - 1 : 0;\n return { l: cursorPosition.lineIndex, c: charIndex };\n }\n\n dispose() {\n this.exitEditingImpl();\n this.draggableTextDelegate.dispose();\n super.dispose();\n }\n}\n\nclassRegistry.setClass(IText);\n// legacy\nclassRegistry.setClass(IText, 'i-text');\n","import type { TClassProperties, TOptions } from '../typedefs';\nimport { IText } from './IText/IText';\nimport { classRegistry } from '../ClassRegistry';\nimport { createTextboxDefaultControls } from '../controls/commonControls';\nimport { JUSTIFY } from './Text/constants';\nimport type { TextStyleDeclaration } from './Text/StyledText';\nimport type { SerializedITextProps, ITextProps } from './IText/IText';\nimport type { ITextEvents } from './IText/ITextBehavior';\nimport type { TextLinesInfo } from './Text/Text';\nimport type { Control } from '../controls/Control';\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textboxDefaultValues: Partial> = {\n minWidth: 20,\n dynamicMinWidth: 2,\n lockScalingFlip: true,\n noScaleCache: false,\n _wordJoiners: /[ \\t\\r]/,\n splitByGrapheme: false,\n};\n\nexport type GraphemeData = {\n wordsData: {\n word: string[];\n width: number;\n }[][];\n largestWordWidth: number;\n};\n\nexport type StyleMap = Record;\n\n// @TODO this is not complete\ninterface UniqueTextboxProps {\n minWidth: number;\n splitByGrapheme: boolean;\n dynamicMinWidth: number;\n _wordJoiners: RegExp;\n}\n\nexport interface SerializedTextboxProps\n extends SerializedITextProps,\n Pick {}\n\nexport interface TextboxProps extends ITextProps, UniqueTextboxProps {}\n\n/**\n * Textbox class, based on IText, allows the user to resize the text rectangle\n * and wraps lines automatically. Textboxes have their Y scaling locked, the\n * user can only change width. Height is adjusted automatically based on the\n * wrapping of lines.\n */\nexport class Textbox<\n Props extends TOptions = Partial,\n SProps extends SerializedTextboxProps = SerializedTextboxProps,\n EventSpec extends ITextEvents = ITextEvents,\n >\n extends IText\n implements UniqueTextboxProps\n{\n /**\n * Minimum width of textbox, in pixels.\n * @type Number\n * @default\n */\n declare minWidth: number;\n\n /**\n * Minimum calculated width of a textbox, in pixels.\n * fixed to 2 so that an empty textbox cannot go to 0\n * and is still selectable without text.\n * @type Number\n * @default\n */\n declare dynamicMinWidth: number;\n\n /**\n * Use this boolean property in order to split strings that have no white space concept.\n * this is a cheap way to help with chinese/japanese\n * @type Boolean\n * @since 2.6.0\n */\n declare splitByGrapheme: boolean;\n\n declare _wordJoiners: RegExp;\n\n declare _styleMap: StyleMap;\n\n declare isWrapping: boolean;\n\n static type = 'Textbox';\n\n static textLayoutProperties = [...IText.textLayoutProperties, 'width'];\n\n static ownDefaults = textboxDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...Textbox.ownDefaults,\n };\n }\n\n /**\n * Constructor\n * @param {String} text Text string\n * @param {Object} [options] Options object\n */\n constructor(text: string, options?: Props) {\n super(text, { ...Textbox.ownDefaults, ...options } as Props);\n }\n\n /**\n * Creates the default control object.\n * If you prefer to have on instance of controls shared among all objects\n * make this function return an empty object and add controls to the ownDefaults object\n */\n static createControls(): { controls: Record } {\n return { controls: createTextboxDefaultControls() };\n }\n\n /**\n * Unlike superclass's version of this function, Textbox does not update\n * its width.\n * @private\n * @override\n */\n initDimensions() {\n if (!this.initialized) {\n return;\n }\n this.isEditing && this.initDelayedCursor();\n this._clearCache();\n // clear dynamicMinWidth as it will be different after we re-wrap line\n this.dynamicMinWidth = 0;\n // wrap lines\n this._styleMap = this._generateStyleMap(this._splitText());\n // if after wrapping, the width is smaller than dynamicMinWidth, change the width and re-wrap\n if (this.dynamicMinWidth > this.width) {\n this._set('width', this.dynamicMinWidth);\n }\n if (this.textAlign.includes(JUSTIFY)) {\n // once text is measured we need to make space fatter to make justified text.\n this.enlargeSpaces();\n }\n // clear cache and re-calculate height\n this.height = this.calcTextHeight();\n }\n\n /**\n * Generate an object that translates the style object so that it is\n * broken up by visual lines (new lines and automatic wrapping).\n * The original text styles object is broken up by actual lines (new lines only),\n * which is only sufficient for Text / IText\n * @private\n */\n _generateStyleMap(textInfo: TextLinesInfo): StyleMap {\n let realLineCount = 0,\n realLineCharCount = 0,\n charCount = 0;\n const map: StyleMap = {};\n\n for (let i = 0; i < textInfo.graphemeLines.length; i++) {\n if (textInfo.graphemeText[charCount] === '\\n' && i > 0) {\n realLineCharCount = 0;\n charCount++;\n realLineCount++;\n } else if (\n !this.splitByGrapheme &&\n this._reSpaceAndTab.test(textInfo.graphemeText[charCount]) &&\n i > 0\n ) {\n // this case deals with space's that are removed from end of lines when wrapping\n realLineCharCount++;\n charCount++;\n }\n\n map[i] = { line: realLineCount, offset: realLineCharCount };\n\n charCount += textInfo.graphemeLines[i].length;\n realLineCharCount += textInfo.graphemeLines[i].length;\n }\n\n return map;\n }\n\n /**\n * Returns true if object has a style property or has it on a specified line\n * @param {Number} lineIndex\n * @return {Boolean}\n */\n styleHas(property: keyof TextStyleDeclaration, lineIndex: number): boolean {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (map) {\n lineIndex = map.line;\n }\n }\n return super.styleHas(property, lineIndex);\n }\n\n /**\n * Returns true if object has no styling or no styling in a line\n * @param {Number} lineIndex , lineIndex is on wrapped lines.\n * @return {Boolean}\n */\n isEmptyStyles(lineIndex: number): boolean {\n if (!this.styles) {\n return true;\n }\n let offset = 0,\n nextLineIndex = lineIndex + 1,\n nextOffset: number,\n shouldLimit = false;\n const map = this._styleMap[lineIndex],\n mapNextLine = this._styleMap[lineIndex + 1];\n if (map) {\n lineIndex = map.line;\n offset = map.offset;\n }\n if (mapNextLine) {\n nextLineIndex = mapNextLine.line;\n shouldLimit = nextLineIndex === lineIndex;\n nextOffset = mapNextLine.offset;\n }\n const obj =\n typeof lineIndex === 'undefined'\n ? this.styles\n : { line: this.styles[lineIndex] };\n for (const p1 in obj) {\n for (const p2 in obj[p1]) {\n const p2Number = parseInt(p2, 10);\n if (p2Number >= offset && (!shouldLimit || p2Number < nextOffset!)) {\n // eslint-disable-next-line no-unused-vars\n for (const p3 in obj[p1][p2]) {\n return false;\n }\n }\n }\n }\n return true;\n }\n\n /**\n * @protected\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @return {TextStyleDeclaration} a style object reference to the existing one or a new empty object when undefined\n */\n _getStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n ): TextStyleDeclaration {\n if (this._styleMap && !this.isWrapping) {\n const map = this._styleMap[lineIndex];\n if (!map) {\n return {};\n }\n lineIndex = map.line;\n charIndex = map.offset + charIndex;\n }\n return super._getStyleDeclaration(lineIndex, charIndex);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @param {Object} style\n * @private\n */\n protected _setStyleDeclaration(\n lineIndex: number,\n charIndex: number,\n style: object,\n ) {\n const map = this._styleMap[lineIndex];\n super._setStyleDeclaration(map.line, map.offset + charIndex, style);\n }\n\n /**\n * @param {Number} lineIndex\n * @param {Number} charIndex\n * @private\n */\n protected _deleteStyleDeclaration(lineIndex: number, charIndex: number) {\n const map = this._styleMap[lineIndex];\n super._deleteStyleDeclaration(map.line, map.offset + charIndex);\n }\n\n /**\n * probably broken need a fix\n * Returns the real style line that correspond to the wrapped lineIndex line\n * Used just to verify if the line does exist or not.\n * @param {Number} lineIndex\n * @returns {Boolean} if the line exists or not\n * @private\n */\n protected _getLineStyle(lineIndex: number): boolean {\n const map = this._styleMap[lineIndex];\n return !!this.styles[map.line];\n }\n\n /**\n * Set the line style to an empty object so that is initialized\n * @param {Number} lineIndex\n * @param {Object} style\n * @private\n */\n protected _setLineStyle(lineIndex: number) {\n const map = this._styleMap[lineIndex];\n super._setLineStyle(map.line);\n }\n\n /**\n * Wraps text using the 'width' property of Textbox. First this function\n * splits text on newlines, so we preserve newlines entered by the user.\n * Then it wraps each line using the width of the Textbox by calling\n * _wrapLine().\n * @param {Array} lines The string array of text that is split into lines\n * @param {Number} desiredWidth width you want to wrap to\n * @returns {Array} Array of lines\n */\n _wrapText(lines: string[], desiredWidth: number): string[][] {\n this.isWrapping = true;\n // extract all thewords and the widths to optimally wrap lines.\n const data = this.getGraphemeDataForRender(lines);\n const wrapped: string[][] = [];\n for (let i = 0; i < data.wordsData.length; i++) {\n wrapped.push(...this._wrapLine(i, desiredWidth, data));\n }\n this.isWrapping = false;\n return wrapped;\n }\n\n /**\n * For each line of text terminated by an hard line stop,\n * measure each word width and extract the largest word from all.\n * The returned words here are the one that at the end will be rendered.\n * @param {string[]} lines the lines we need to measure\n *\n */\n getGraphemeDataForRender(lines: string[]): GraphemeData {\n const splitByGrapheme = this.splitByGrapheme,\n infix = splitByGrapheme ? '' : ' ';\n\n let largestWordWidth = 0;\n\n const data = lines.map((line, lineIndex) => {\n let offset = 0;\n const wordsOrGraphemes = splitByGrapheme\n ? this.graphemeSplit(line)\n : this.wordSplit(line);\n\n if (wordsOrGraphemes.length === 0) {\n return [{ word: [], width: 0 }];\n }\n\n return wordsOrGraphemes.map((word: string) => {\n // if using splitByGrapheme words are already in graphemes.\n const graphemeArray = splitByGrapheme\n ? [word]\n : this.graphemeSplit(word);\n const width = this._measureWord(graphemeArray, lineIndex, offset);\n largestWordWidth = Math.max(width, largestWordWidth);\n offset += graphemeArray.length + infix.length;\n return { word: graphemeArray, width };\n });\n });\n\n return {\n wordsData: data,\n largestWordWidth,\n };\n }\n\n /**\n * Helper function to measure a string of text, given its lineIndex and charIndex offset\n * It gets called when charBounds are not available yet.\n * Override if necessary\n * Use with {@link Textbox#wordSplit}\n *\n * @param {CanvasRenderingContext2D} ctx\n * @param {String} text\n * @param {number} lineIndex\n * @param {number} charOffset\n * @returns {number}\n */\n _measureWord(word: string[], lineIndex: number, charOffset = 0): number {\n let width = 0,\n prevGrapheme;\n const skipLeft = true;\n for (let i = 0, len = word.length; i < len; i++) {\n const box = this._getGraphemeBox(\n word[i],\n lineIndex,\n i + charOffset,\n prevGrapheme,\n skipLeft,\n );\n width += box.kernedWidth;\n prevGrapheme = word[i];\n }\n return width;\n }\n\n /**\n * Override this method to customize word splitting\n * Use with {@link Textbox#_measureWord}\n * @param {string} value\n * @returns {string[]} array of words\n */\n wordSplit(value: string): string[] {\n return value.split(this._wordJoiners);\n }\n\n /**\n * Wraps a line of text using the width of the Textbox as desiredWidth\n * and leveraging the known width o words from GraphemeData\n * @private\n * @param {Number} lineIndex\n * @param {Number} desiredWidth width you want to wrap the line to\n * @param {GraphemeData} graphemeData an object containing all the lines' words width.\n * @param {Number} reservedSpace space to remove from wrapping for custom functionalities\n * @returns {Array} Array of line(s) into which the given text is wrapped\n * to.\n */\n _wrapLine(\n lineIndex: number,\n desiredWidth: number,\n { largestWordWidth, wordsData }: GraphemeData,\n reservedSpace = 0,\n ): string[][] {\n const additionalSpace = this._getWidthOfCharSpacing(),\n splitByGrapheme = this.splitByGrapheme,\n graphemeLines = [],\n infix = splitByGrapheme ? '' : ' ';\n\n let lineWidth = 0,\n line: string[] = [],\n // spaces in different languages?\n offset = 0,\n infixWidth = 0,\n lineJustStarted = true;\n\n desiredWidth -= reservedSpace;\n\n const maxWidth = Math.max(\n desiredWidth,\n largestWordWidth,\n this.dynamicMinWidth,\n );\n // layout words\n const data = wordsData[lineIndex];\n offset = 0;\n let i;\n for (i = 0; i < data.length; i++) {\n const { word, width: wordWidth } = data[i];\n offset += word.length;\n\n lineWidth += infixWidth + wordWidth - additionalSpace;\n if (lineWidth > maxWidth && !lineJustStarted) {\n graphemeLines.push(line);\n line = [];\n lineWidth = wordWidth;\n lineJustStarted = true;\n } else {\n lineWidth += additionalSpace;\n }\n\n if (!lineJustStarted && !splitByGrapheme) {\n line.push(infix);\n }\n line = line.concat(word);\n\n infixWidth = splitByGrapheme\n ? 0\n : this._measureWord([infix], lineIndex, offset);\n offset++;\n lineJustStarted = false;\n }\n\n i && graphemeLines.push(line);\n\n // TODO: this code is probably not necessary anymore.\n // it can be moved out of this function since largestWordWidth is now\n // known in advance\n if (largestWordWidth + reservedSpace > this.dynamicMinWidth) {\n this.dynamicMinWidth = largestWordWidth - additionalSpace + reservedSpace;\n }\n return graphemeLines;\n }\n\n /**\n * Detect if the text line is ended with an hard break\n * text and itext do not have wrapping, return false\n * @param {Number} lineIndex text to split\n * @return {Boolean}\n */\n isEndOfWrapping(lineIndex: number): boolean {\n if (!this._styleMap[lineIndex + 1]) {\n // is last line, return true;\n return true;\n }\n if (this._styleMap[lineIndex + 1].line !== this._styleMap[lineIndex].line) {\n // this is last line before a line break, return true;\n return true;\n }\n return false;\n }\n\n /**\n * Detect if a line has a linebreak and so we need to account for it when moving\n * and counting style.\n * This is important only for splitByGrapheme at the end of wrapping.\n * If we are not wrapping the offset is always 1\n * @return Number\n */\n missingNewlineOffset(lineIndex: number, skipWrapping?: boolean): 0 | 1 {\n if (this.splitByGrapheme && !skipWrapping) {\n return this.isEndOfWrapping(lineIndex) ? 1 : 0;\n }\n return 1;\n }\n\n /**\n * Gets lines of text to render in the Textbox. This function calculates\n * text wrapping on the fly every time it is called.\n * @param {String} text text to split\n * @returns {Array} Array of lines in the Textbox.\n * @override\n */\n _splitTextIntoLines(text: string) {\n const newText = super._splitTextIntoLines(text),\n graphemeLines = this._wrapText(newText.lines, this.width),\n lines = new Array(graphemeLines.length);\n for (let i = 0; i < graphemeLines.length; i++) {\n lines[i] = graphemeLines[i].join('');\n }\n newText.lines = lines;\n newText.graphemeLines = graphemeLines;\n return newText;\n }\n\n getMinWidth() {\n return Math.max(this.minWidth, this.dynamicMinWidth);\n }\n\n _removeExtraneousStyles() {\n const linesToKeep = new Map();\n for (const prop in this._styleMap) {\n const propNumber = parseInt(prop, 10);\n if (this._textLines[propNumber]) {\n const lineIndex = this._styleMap[prop].line;\n linesToKeep.set(`${lineIndex}`, true);\n }\n }\n for (const prop in this.styles) {\n if (!linesToKeep.has(prop)) {\n delete this.styles[prop];\n }\n }\n }\n\n /**\n * Returns object representation of an instance\n * @method toObject\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n return super.toObject([\n 'minWidth',\n 'splitByGrapheme',\n ...propertiesToInclude,\n ] as K[]) as Pick & SProps;\n }\n}\n\nclassRegistry.setClass(Textbox);\n","import { Point } from '../../Point';\nimport type { FabricObject } from '../../shapes/Object/FabricObject';\nimport { makeBoundingBoxFromPoints } from '../../util/misc/boundingBoxFromPoints';\nimport { sendPointToPlane } from '../../util/misc/planeChange';\nimport type { LayoutStrategyResult, StrictLayoutContext } from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { getObjectBounds } from './utils';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will adjust the bounding box to match the clip path bounding box.\n */\nexport class ClipPathLayout extends LayoutStrategy {\n static readonly type = 'clip-path';\n\n shouldPerformLayout(context: StrictLayoutContext): boolean {\n return !!context.target.clipPath && super.shouldPerformLayout(context);\n }\n\n shouldLayoutClipPath() {\n return false;\n }\n\n calcLayoutResult(\n context: StrictLayoutContext,\n objects: FabricObject[],\n ): LayoutStrategyResult | undefined {\n const { target } = context;\n const { clipPath, group } = target;\n if (!clipPath || !this.shouldPerformLayout(context)) {\n return;\n }\n // TODO: remove stroke calculation from this case\n const { width, height } = makeBoundingBoxFromPoints(\n getObjectBounds(target, clipPath as FabricObject),\n );\n const size = new Point(width, height);\n if (clipPath.absolutePositioned) {\n // we want the center point to exist in group's containing plane\n const clipPathCenter = sendPointToPlane(\n clipPath.getRelativeCenterPoint(),\n undefined,\n group ? group.calcTransformMatrix() : undefined,\n );\n return {\n center: clipPathCenter,\n size,\n };\n } else {\n // we want the center point to exist in group's containing plane, so we send it upwards\n const clipPathCenter = clipPath\n .getRelativeCenterPoint()\n .transform(target.calcOwnMatrix(), true);\n if (this.shouldPerformLayout(context)) {\n // the clip path is positioned relative to the group's center which is affected by the bbox\n // so we first calculate the bbox\n const { center = new Point(), correction = new Point() } =\n this.calcBoundingBox(objects, context) || {};\n return {\n center: center.add(clipPathCenter),\n correction: correction.subtract(clipPathCenter),\n size,\n };\n } else {\n return {\n center: target.getRelativeCenterPoint().add(clipPathCenter),\n size,\n };\n }\n }\n }\n}\n\nclassRegistry.setClass(ClipPathLayout);\n","import { Point } from '../../Point';\nimport type {\n InitializationLayoutContext,\n LayoutStrategyResult,\n StrictLayoutContext,\n} from '../types';\nimport { LayoutStrategy } from './LayoutStrategy';\nimport { classRegistry } from '../../ClassRegistry';\n\n/**\n * Layout will keep target's initial size.\n */\nexport class FixedLayout extends LayoutStrategy {\n static readonly type = 'fixed';\n\n /**\n * @override respect target's initial size\n */\n getInitialSize(\n { target }: StrictLayoutContext & InitializationLayoutContext,\n { size }: Pick,\n ): Point {\n return new Point(target.width || size.x, target.height || size.y);\n }\n}\n\nclassRegistry.setClass(FixedLayout);\n","import { LayoutManager } from './LayoutManager';\nimport type { RegistrationContext, StrictLayoutContext } from './types';\nimport type { Group } from '../shapes/Group';\n\n/**\n * Today the LayoutManager class also takes care of subscribing event handlers\n * to update the group layout when the group is interactive and a transform is applied\n * to a child object.\n * The ActiveSelection is never interactive, but it could contain objects from\n * groups that are.\n * The standard LayoutManager would subscribe the children of the activeSelection to\n * perform layout changes to the active selection itself, what we need instead is that\n * the transformation applied to the active selection will trigger changes to the\n * original group of the children ( the one referenced under the parent property )\n * This subclass of the LayoutManager has a single duty to fill the gap of this difference.`\n */\nexport class ActiveSelectionLayoutManager extends LayoutManager {\n subscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n parent.layoutManager.subscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n\n /**\n * unsubscribe from parent only if all its children were deselected\n */\n unsubscribeTargets(\n context: RegistrationContext & Partial,\n ): void {\n const activeSelection = context.target;\n const selectedObjects = activeSelection.getObjects();\n const parents = context.targets.reduce((parents, target) => {\n target.parent && parents.add(target.parent);\n return parents;\n }, new Set());\n parents.forEach((parent) => {\n !selectedObjects.some((object) => object.parent === parent) &&\n parent.layoutManager.unsubscribeTargets({\n target: parent,\n targets: [activeSelection],\n });\n });\n }\n}\n","import type { ControlRenderingStyleOverride } from '../controls/controlRendering';\nimport { classRegistry } from '../ClassRegistry';\nimport type { GroupProps } from './Group';\nimport { Group } from './Group';\nimport type { FabricObject } from './Object/FabricObject';\nimport {\n LAYOUT_TYPE_ADDED,\n LAYOUT_TYPE_REMOVED,\n} from '../LayoutManager/constants';\nimport type { TClassProperties } from '../typedefs';\nimport { log } from '../util/internals/console';\nimport { ActiveSelectionLayoutManager } from '../LayoutManager/ActiveSelectionLayoutManager';\n\nexport type MultiSelectionStacking = 'canvas-stacking' | 'selection-order';\n\nexport interface ActiveSelectionOptions extends GroupProps {\n multiSelectionStacking: MultiSelectionStacking;\n}\n\nconst activeSelectionDefaultValues: Partial> =\n {\n multiSelectionStacking: 'canvas-stacking',\n };\n\n/**\n * Used by Canvas to manage selection.\n *\n * @example\n * class MyActiveSelection extends ActiveSelection {\n * ...\n * }\n *\n * // override the default `ActiveSelection` class\n * classRegistry.setClass(MyActiveSelection)\n */\nexport class ActiveSelection extends Group {\n static type = 'ActiveSelection';\n\n static ownDefaults: Record = activeSelectionDefaultValues;\n\n static getDefaults(): Record {\n return { ...super.getDefaults(), ...ActiveSelection.ownDefaults };\n }\n\n /**\n * The ActiveSelection needs to use the ActiveSelectionLayoutManager\n * or selections on interactive groups may be broken\n */\n declare layoutManager: ActiveSelectionLayoutManager;\n\n /**\n * controls how selected objects are added during a multiselection event\n * - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order\n * - `selection-order` adds the selected object to the top of the stack,\n * meaning that the stack is ordered by the order in which objects were selected\n * @default `canvas-stacking`\n */\n declare multiSelectionStacking: MultiSelectionStacking;\n\n constructor(\n objects: FabricObject[] = [],\n options: Partial = {},\n ) {\n super();\n Object.assign(this, ActiveSelection.ownDefaults);\n this.setOptions(options);\n const { left, top, layoutManager } = options;\n this.groupInit(objects, {\n left,\n top,\n layoutManager: layoutManager ?? new ActiveSelectionLayoutManager(),\n });\n }\n\n /**\n * @private\n */\n _shouldSetNestedCoords() {\n return true;\n }\n\n /**\n * @private\n * @override we don't want the selection monitor to be active\n */\n __objectSelectionMonitor() {\n // noop\n }\n\n /**\n * Adds objects with respect to {@link multiSelectionStacking}\n * @param targets object to add to selection\n */\n multiSelectAdd(...targets: FabricObject[]) {\n if (this.multiSelectionStacking === 'selection-order') {\n this.add(...targets);\n } else {\n // respect object stacking as it is on canvas\n // perf enhancement for large ActiveSelection: consider a binary search of `isInFrontOf`\n targets.forEach((target) => {\n const index = this._objects.findIndex((obj) => obj.isInFrontOf(target));\n const insertAt =\n index === -1\n ? // `target` is in front of all other objects\n this.size()\n : index;\n this.insertAt(insertAt, target);\n });\n }\n }\n\n /**\n * @override block ancestors/descendants of selected objects from being selected to prevent a circular object tree\n */\n canEnterGroup(object: FabricObject) {\n if (\n this.getObjects().some(\n (o) => o.isDescendantOf(object) || object.isDescendantOf(o),\n )\n ) {\n // prevent circular object tree\n log(\n 'error',\n 'ActiveSelection: circular object trees are not supported, this call has no effect',\n );\n return false;\n }\n\n return super.canEnterGroup(object);\n }\n\n /**\n * Change an object so that it can be part of an active selection.\n * this method is called by multiselectAdd from canvas code.\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object is in canvas coordinate plane\n */\n enterGroup(object: FabricObject, removeParentTransform?: boolean) {\n // This condition check that the object has currently a group, and the group\n // is also its parent, meaning that is not in an active selection, but is\n // in a normal group.\n if (object.parent && object.parent === object.group) {\n // Disconnect the object from the group functionalities, but keep the ref parent intact\n // for later re-enter\n object.parent._exitGroup(object);\n // in this case the object is probably inside an active selection.\n } else if (object.group && object.parent !== object.group) {\n // in this case group.remove will also clear the old parent reference.\n object.group.remove(object);\n }\n // enter the active selection from a render perspective\n // the object will be in the objects array of both the ActiveSelection and the Group\n // but referenced in the group's _activeObjects so that it won't be rendered twice.\n this._enterGroup(object, removeParentTransform);\n }\n\n /**\n * we want objects to retain their canvas ref when exiting instance\n * @private\n * @param {FabricObject} object\n * @param {boolean} [removeParentTransform] true if object should exit group without applying group's transform to it\n */\n exitGroup(object: FabricObject, removeParentTransform?: boolean) {\n this._exitGroup(object, removeParentTransform);\n // return to parent\n object.parent && object.parent._enterGroup(object, true);\n }\n\n /**\n * @private\n * @param {'added'|'removed'} type\n * @param {FabricObject[]} targets\n */\n _onAfterObjectsChange(type: 'added' | 'removed', targets: FabricObject[]) {\n super._onAfterObjectsChange(type, targets);\n const groups = new Set();\n targets.forEach((object) => {\n const { parent } = object;\n parent && groups.add(parent);\n });\n if (type === LAYOUT_TYPE_REMOVED) {\n // invalidate groups' layout and mark as dirty\n groups.forEach((group) => {\n group._onAfterObjectsChange(LAYOUT_TYPE_ADDED, targets);\n });\n } else {\n // mark groups as dirty\n groups.forEach((group) => {\n group._set('dirty', true);\n });\n }\n }\n\n /**\n * @override remove all objects\n */\n onDeselect() {\n this.removeAll();\n return false;\n }\n\n /**\n * Returns string representation of a group\n * @return {String}\n */\n toString() {\n return `#`;\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * objectCaching is a global flag, wins over everything\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * @return {Boolean}\n */\n shouldCache() {\n return false;\n }\n\n /**\n * Check if this group or its parent group are caching, recursively up\n * @return {Boolean}\n */\n isOnACache() {\n return false;\n }\n\n /**\n * Renders controls and borders for the object\n * @param {CanvasRenderingContext2D} ctx Context to render on\n * @param {Object} [styleOverride] properties to override the object style\n * @param {Object} [childrenOverride] properties to override the children overrides\n */\n _renderControls(\n ctx: CanvasRenderingContext2D,\n styleOverride?: ControlRenderingStyleOverride,\n childrenOverride?: ControlRenderingStyleOverride,\n ) {\n ctx.save();\n ctx.globalAlpha = this.isMoving ? this.borderOpacityWhenMoving : 1;\n const options = {\n hasControls: false,\n ...childrenOverride,\n forActiveSelection: true,\n };\n for (let i = 0; i < this._objects.length; i++) {\n this._objects[i]._renderControls(ctx, options);\n }\n super._renderControls(ctx, styleOverride);\n ctx.restore();\n }\n}\n\nclassRegistry.setClass(ActiveSelection);\nclassRegistry.setClass(ActiveSelection, 'activeSelection');\n","/**\n * Canvas 2D filter backend.\n */\nimport type { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TPipelineResources } from './typedefs';\n\nexport class Canvas2dFilterBackend {\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n /**\n * Apply a set of filters against a source image and draw the filtered output\n * to the provided destination canvas.\n *\n * @param {EnhancedFilter} filters The filter to apply.\n * @param {HTMLImageElement|HTMLCanvasElement} sourceElement The source to be filtered.\n * @param {Number} sourceWidth The width of the source input.\n * @param {Number} sourceHeight The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n */\n applyFilters(\n filters: BaseFilter>[],\n sourceElement: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n targetCanvas: HTMLCanvasElement,\n ): T2DPipelineState | void {\n const ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.drawImage(sourceElement, 0, 0, sourceWidth, sourceHeight);\n const imageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const originalImageData = ctx.getImageData(0, 0, sourceWidth, sourceHeight);\n const pipelineState: T2DPipelineState = {\n sourceWidth,\n sourceHeight,\n imageData,\n originalEl: sourceElement,\n originalImageData,\n canvasEl: targetCanvas,\n ctx,\n filterBackend: this,\n };\n filters.forEach((filter) => {\n filter.applyTo(pipelineState);\n });\n const { imageData: imageDataPostFilter } = pipelineState;\n if (\n imageDataPostFilter.width !== sourceWidth ||\n imageDataPostFilter.height !== sourceHeight\n ) {\n targetCanvas.width = imageDataPostFilter.width;\n targetCanvas.height = imageDataPostFilter.height;\n }\n ctx.putImageData(imageDataPostFilter, 0, 0);\n return pipelineState;\n }\n}\n","import { config } from '../config';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport type {\n TWebGLPipelineState,\n TProgramCache,\n TTextureCache,\n TPipelineResources,\n} from './typedefs';\nimport type { BaseFilter } from './BaseFilter';\n\nexport class WebGLFilterBackend {\n declare tileSize: number;\n\n /**\n * Define ...\n **/\n aPosition: Float32Array = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]);\n\n /**\n * If GLPut data is the fastest operation, or if forced, this buffer will be used\n * to transfer the data back in the 2d logic\n **/\n declare imageBuffer?: ArrayBuffer;\n\n declare canvas: HTMLCanvasElement;\n\n /**\n * The Webgl context that will execute the operations for filtering\n **/\n declare gl: WebGLRenderingContext;\n\n /**\n * Keyed map for shader cache\n **/\n declare programCache: TProgramCache;\n\n /**\n * Keyed map for texture cache\n **/\n declare textureCache: TTextureCache;\n\n /**\n * Contains GPU info for debug\n **/\n declare gpuInfo: any;\n\n /**\n * Experimental. This object is a sort of repository of help layers used to avoid\n * of recreating them during frequent filtering. If you are previewing a filter with\n * a slider you probably do not want to create help layers every filter step.\n * in this object there will be appended some canvases, created once, resized sometimes\n * cleared never. Clearing is left to the developer.\n **/\n resources: TPipelineResources = {};\n\n constructor({ tileSize = config.textureSize } = {}) {\n this.tileSize = tileSize;\n this.setupGLContext(tileSize, tileSize);\n this.captureGPUInfo();\n }\n\n /**\n * Setup a WebGL context suitable for filtering, and bind any needed event handlers.\n */\n setupGLContext(width: number, height: number): void {\n this.dispose();\n this.createWebGLCanvas(width, height);\n }\n\n /**\n * Create a canvas element and associated WebGL context and attaches them as\n * class properties to the GLFilterBackend class.\n */\n createWebGLCanvas(width: number, height: number): void {\n const canvas = createCanvasElementFor({ width, height });\n const glOptions = {\n alpha: true,\n premultipliedAlpha: false,\n depth: false,\n stencil: false,\n antialias: false,\n },\n gl = canvas.getContext('webgl', glOptions) as WebGLRenderingContext;\n\n if (!gl) {\n return;\n }\n gl.clearColor(0, 0, 0, 0);\n // this canvas can fire webglcontextlost and webglcontextrestored\n this.canvas = canvas;\n this.gl = gl;\n }\n\n /**\n * Attempts to apply the requested filters to the source provided, drawing the filtered output\n * to the provided target canvas.\n *\n * @param {Array} filters The filters to apply.\n * @param {TexImageSource} source The source to be filtered.\n * @param {Number} width The width of the source input.\n * @param {Number} height The height of the source input.\n * @param {HTMLCanvasElement} targetCanvas The destination for filtered output to be drawn.\n * @param {String|undefined} cacheKey A key used to cache resources related to the source. If\n * omitted, caching will be skipped.\n */\n applyFilters(\n filters: BaseFilter>[],\n source: TexImageSource,\n width: number,\n height: number,\n targetCanvas: HTMLCanvasElement,\n cacheKey?: string,\n ): TWebGLPipelineState | undefined {\n const gl = this.gl;\n const ctx = targetCanvas.getContext('2d');\n if (!gl || !ctx) {\n return;\n }\n let cachedTexture;\n if (cacheKey) {\n cachedTexture = this.getCachedTexture(cacheKey, source);\n }\n const pipelineState: TWebGLPipelineState = {\n originalWidth:\n (source as HTMLImageElement).width ||\n (source as HTMLImageElement).naturalWidth ||\n 0,\n originalHeight:\n (source as HTMLImageElement).height ||\n (source as HTMLImageElement).naturalHeight ||\n 0,\n sourceWidth: width,\n sourceHeight: height,\n destinationWidth: width,\n destinationHeight: height,\n context: gl,\n sourceTexture: this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n ),\n targetTexture: this.createTexture(gl, width, height),\n originalTexture:\n cachedTexture ||\n this.createTexture(\n gl,\n width,\n height,\n !cachedTexture ? source : undefined,\n )!,\n passes: filters.length,\n webgl: true,\n aPosition: this.aPosition,\n programCache: this.programCache,\n pass: 0,\n filterBackend: this,\n targetCanvas: targetCanvas,\n };\n const tempFbo = gl.createFramebuffer();\n gl.bindFramebuffer(gl.FRAMEBUFFER, tempFbo);\n filters.forEach((filter: any) => {\n filter && filter.applyTo(pipelineState);\n });\n resizeCanvasIfNeeded(pipelineState);\n this.copyGLTo2D(gl, pipelineState);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.deleteTexture(pipelineState.sourceTexture);\n gl.deleteTexture(pipelineState.targetTexture);\n gl.deleteFramebuffer(tempFbo);\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n return pipelineState;\n }\n\n /**\n * Detach event listeners, remove references, and clean up caches.\n */\n dispose() {\n if (this.canvas) {\n // we are disposing, we don't care about the fact\n // that the canvas shouldn't be null.\n // @ts-expect-error disposing\n this.canvas = null;\n // @ts-expect-error disposing\n this.gl = null;\n }\n this.clearWebGLCaches();\n }\n\n /**\n * Wipe out WebGL-related caches.\n */\n clearWebGLCaches() {\n this.programCache = {};\n this.textureCache = {};\n }\n\n /**\n * Create a WebGL texture object.\n *\n * Accepts specific dimensions to initialize the texture to or a source image.\n *\n * @param {WebGLRenderingContext} gl The GL context to use for creating the texture.\n * @param {number} width The width to initialize the texture at.\n * @param {number} height The height to initialize the texture.\n * @param {TexImageSource} textureImageSource A source for the texture data.\n * @param {number} filter gl.NEAREST default or gl.LINEAR filters for the texture.\n * This filter is very useful for LUTs filters. If you need interpolation use gl.LINEAR\n * @returns {WebGLTexture}\n */\n createTexture(\n gl: WebGLRenderingContext,\n width: number,\n height: number,\n textureImageSource?: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ) {\n const {\n NEAREST,\n TEXTURE_2D,\n RGBA,\n UNSIGNED_BYTE,\n CLAMP_TO_EDGE,\n TEXTURE_MAG_FILTER,\n TEXTURE_MIN_FILTER,\n TEXTURE_WRAP_S,\n TEXTURE_WRAP_T,\n } = gl;\n const texture = gl.createTexture();\n gl.bindTexture(TEXTURE_2D, texture);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, filter || NEAREST);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);\n gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);\n if (textureImageSource) {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n RGBA,\n UNSIGNED_BYTE,\n textureImageSource,\n );\n } else {\n gl.texImage2D(\n TEXTURE_2D,\n 0,\n RGBA,\n width,\n height,\n 0,\n RGBA,\n UNSIGNED_BYTE,\n null,\n );\n }\n return texture;\n }\n\n /**\n * Can be optionally used to get a texture from the cache array\n *\n * If an existing texture is not found, a new texture is created and cached.\n *\n * @param {String} uniqueId A cache key to use to find an existing texture.\n * @param {HTMLImageElement|HTMLCanvasElement} textureImageSource A source to use to create the\n * texture cache entry if one does not already exist.\n */\n getCachedTexture(\n uniqueId: string,\n textureImageSource: TexImageSource,\n filter?:\n | WebGLRenderingContextBase['NEAREST']\n | WebGLRenderingContextBase['LINEAR'],\n ): WebGLTexture | null {\n const { textureCache } = this;\n if (textureCache[uniqueId]) {\n return textureCache[uniqueId];\n } else {\n const texture = this.createTexture(\n this.gl,\n (textureImageSource as HTMLImageElement).width,\n (textureImageSource as HTMLImageElement).height,\n textureImageSource,\n filter,\n );\n if (texture) {\n textureCache[uniqueId] = texture;\n }\n return texture;\n }\n }\n\n /**\n * Clear out cached resources related to a source image that has been\n * filtered previously.\n *\n * @param {String} cacheKey The cache key provided when the source image was filtered.\n */\n evictCachesForKey(cacheKey: string) {\n if (this.textureCache[cacheKey]) {\n this.gl.deleteTexture(this.textureCache[cacheKey]);\n delete this.textureCache[cacheKey];\n }\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas.\n *\n * The WebGL canvas is assumed to be upside down, with the top-left pixel of the\n * desired output image appearing in the bottom-left corner of the WebGL canvas.\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2D(gl: WebGLRenderingContext, pipelineState: TWebGLPipelineState) {\n const glCanvas = gl.canvas,\n targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d');\n if (!ctx) {\n return;\n }\n ctx.translate(0, targetCanvas.height); // move it down again\n ctx.scale(1, -1); // vertical flip\n // where is my image on the big glcanvas?\n const sourceY = glCanvas.height - targetCanvas.height;\n ctx.drawImage(\n glCanvas,\n 0,\n sourceY,\n targetCanvas.width,\n targetCanvas.height,\n 0,\n 0,\n targetCanvas.width,\n targetCanvas.height,\n );\n }\n\n /**\n * Copy an input WebGL canvas on to an output 2D canvas using 2d canvas' putImageData\n * API. Measurably faster than using ctx.drawImage in Firefox (version 54 on OSX Sierra).\n *\n * @param {WebGLRenderingContext} sourceContext The WebGL context to copy from.\n * @param {HTMLCanvasElement} targetCanvas The 2D target canvas to copy on to.\n * @param {Object} pipelineState The 2D target canvas to copy on to.\n */\n copyGLTo2DPutImageData(\n this: Required,\n gl: WebGLRenderingContext,\n pipelineState: TWebGLPipelineState,\n ) {\n const targetCanvas = pipelineState.targetCanvas,\n ctx = targetCanvas.getContext('2d'),\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight,\n numBytes = dWidth * dHeight * 4;\n if (!ctx) {\n return;\n }\n const u8 = new Uint8Array(this.imageBuffer, 0, numBytes);\n const u8Clamped = new Uint8ClampedArray(this.imageBuffer, 0, numBytes);\n\n gl.readPixels(0, 0, dWidth, dHeight, gl.RGBA, gl.UNSIGNED_BYTE, u8);\n const imgData = new ImageData(u8Clamped, dWidth, dHeight);\n ctx.putImageData(imgData, 0, 0);\n }\n\n /**\n * Attempt to extract GPU information strings from a WebGL context.\n *\n * Useful information when debugging or blacklisting specific GPUs.\n *\n * @returns {Object} A GPU info object with renderer and vendor strings.\n */\n captureGPUInfo() {\n if (this.gpuInfo) {\n return this.gpuInfo;\n }\n const gl = this.gl,\n gpuInfo = { renderer: '', vendor: '' };\n if (!gl) {\n return gpuInfo;\n }\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n if (ext) {\n const renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);\n const vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);\n if (renderer) {\n gpuInfo.renderer = renderer.toLowerCase();\n }\n if (vendor) {\n gpuInfo.vendor = vendor.toLowerCase();\n }\n }\n this.gpuInfo = gpuInfo;\n return gpuInfo;\n }\n}\n\nfunction resizeCanvasIfNeeded(pipelineState: TWebGLPipelineState): void {\n const targetCanvas = pipelineState.targetCanvas,\n width = targetCanvas.width,\n height = targetCanvas.height,\n dWidth = pipelineState.destinationWidth,\n dHeight = pipelineState.destinationHeight;\n\n if (width !== dWidth || height !== dHeight) {\n targetCanvas.width = dWidth;\n targetCanvas.height = dHeight;\n }\n}\n","import { config } from '../config';\nimport { getEnv } from '../env';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { Canvas2dFilterBackend } from './Canvas2dFilterBackend';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\n\nexport type FilterBackend = WebGLFilterBackend | Canvas2dFilterBackend;\n\nlet filterBackend: FilterBackend;\n\n/**\n * Verifies if it is possible to initialize webgl or fallback on a canvas2d filtering backend\n */\nexport function initFilterBackend(): FilterBackend {\n const { WebGLProbe } = getEnv();\n WebGLProbe.queryWebGL(createCanvasElement());\n if (config.enableGLFiltering && WebGLProbe.isSupported(config.textureSize)) {\n return new WebGLFilterBackend({ tileSize: config.textureSize });\n } else {\n return new Canvas2dFilterBackend();\n }\n}\n\n/**\n * Get the current fabricJS filter backend or initialize one if not available yet\n * @param [strict] pass `true` to create the backend if it wasn't created yet (default behavior),\n * pass `false` to get the backend ref without mutating it\n */\nexport function getFilterBackend(strict = true): FilterBackend {\n if (!filterBackend && strict) {\n filterBackend = initFilterBackend();\n }\n return filterBackend;\n}\n\nexport function setFilterBackend(backend: FilterBackend) {\n filterBackend = backend;\n}\n","import { getFabricDocument, getEnv } from '../env';\nimport type { BaseFilter } from '../filters/BaseFilter';\nimport { getFilterBackend } from '../filters/FilterBackend';\nimport { SHARED_ATTRIBUTES } from '../parser/attributes';\nimport { parseAttributes } from '../parser/parseAttributes';\nimport type {\n TClassProperties,\n TCrossOrigin,\n TSize,\n Abortable,\n TOptions,\n} from '../typedefs';\nimport { uid } from '../util/internals/uid';\nimport { createCanvasElementFor } from '../util/misc/dom';\nimport { findScaleToCover, findScaleToFit } from '../util/misc/findScaleTo';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport {\n enlivenObjectEnlivables,\n enlivenObjects,\n loadImage,\n} from '../util/misc/objectEnlive';\nimport { parsePreserveAspectRatioAttribute } from '../util/misc/svgParsing';\nimport { classRegistry } from '../ClassRegistry';\nimport { FabricObject, cacheProperties } from './Object/FabricObject';\nimport type { FabricObjectProps, SerializedObjectProps } from './Object/types';\nimport type { ObjectEvents } from '../EventTypeDefs';\nimport { WebGLFilterBackend } from '../filters/WebGLFilterBackend';\nimport { FILL, NONE } from '../constants';\nimport { getDocumentFromElement } from '../util/dom_misc';\nimport type { CSSRules } from '../parser/typedefs';\nimport type { Resize } from '../filters/Resize';\nimport type { TCachedFabricObject } from './Object/Object';\nimport { log } from '../util/internals/console';\n\n// @todo Would be nice to have filtering code not imported directly.\n\nexport type ImageSource =\n | HTMLImageElement\n | HTMLVideoElement\n | HTMLCanvasElement;\n\ninterface UniqueImageProps {\n srcFromAttribute: boolean;\n minimumScaleTrigger: number;\n cropX: number;\n cropY: number;\n imageSmoothing: boolean;\n filters: BaseFilter>[];\n resizeFilter?: Resize;\n}\n\nexport const imageDefaultValues: Partial> = {\n strokeWidth: 0,\n srcFromAttribute: false,\n minimumScaleTrigger: 0.5,\n cropX: 0,\n cropY: 0,\n imageSmoothing: true,\n};\n\nexport interface SerializedImageProps extends SerializedObjectProps {\n src: string;\n crossOrigin: TCrossOrigin;\n filters: any[];\n resizeFilter?: any;\n cropX: number;\n cropY: number;\n}\n\nexport interface ImageProps extends FabricObjectProps, UniqueImageProps {}\n\nconst IMAGE_PROPS = ['cropX', 'cropY'] as const;\n\n/**\n * @tutorial {@link http://fabricjs.com/fabric-intro-part-1#images}\n */\nexport class FabricImage<\n Props extends TOptions = Partial,\n SProps extends SerializedImageProps = SerializedImageProps,\n EventSpec extends ObjectEvents = ObjectEvents,\n >\n extends FabricObject\n implements ImageProps\n{\n /**\n * When calling {@link FabricImage.getSrc}, return value from element src with `element.getAttribute('src')`.\n * This allows for relative urls as image src.\n * @since 2.7.0\n * @type Boolean\n * @default false\n */\n declare srcFromAttribute: boolean;\n\n /**\n * private\n * contains last value of scaleX to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleX = 1;\n\n /**\n * private\n * contains last value of scaleY to detect\n * if the Image got resized after the last Render\n * @type Number\n */\n protected _lastScaleY = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingX = 1;\n\n /**\n * private\n * contains last value of scaling applied by the apply filter chain\n * @type Number\n */\n protected _filterScalingY = 1;\n\n /**\n * minimum scale factor under which any resizeFilter is triggered to resize the image\n * 0 will disable the automatic resize. 1 will trigger automatically always.\n * number bigger than 1 are not implemented yet.\n * @type Number\n */\n declare minimumScaleTrigger: number;\n\n /**\n * key used to retrieve the texture representing this image\n * @since 2.0.0\n * @type String\n * @default\n */\n declare cacheKey: string;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropX: number;\n\n /**\n * Image crop in pixels from original image size.\n * @since 2.0.0\n * @type Number\n * @default\n */\n declare cropY: number;\n\n /**\n * Indicates whether this canvas will use image smoothing when painting this image.\n * Also influence if the cacheCanvas for this image uses imageSmoothing\n * @since 4.0.0-beta.11\n * @type Boolean\n * @default\n */\n declare imageSmoothing: boolean;\n\n declare preserveAspectRatio: string;\n\n protected declare src: string;\n\n declare filters: BaseFilter>[];\n declare resizeFilter: Resize;\n\n declare _element: ImageSource;\n declare _filteredEl?: HTMLCanvasElement;\n declare _originalElement: ImageSource;\n\n static type = 'Image';\n\n static cacheProperties = [...cacheProperties, ...IMAGE_PROPS];\n\n static ownDefaults = imageDefaultValues;\n\n static getDefaults(): Record {\n return {\n ...super.getDefaults(),\n ...FabricImage.ownDefaults,\n };\n }\n /**\n * Constructor\n * Image can be initialized with any canvas drawable or a string.\n * The string should be a url and will be loaded as an image.\n * Canvas and Image element work out of the box, while videos require extra code to work.\n * Please check video element events for seeking.\n * @param {ImageSource | string} element Image element\n * @param {Object} [options] Options object\n */\n constructor(elementId: string, options?: Props);\n constructor(element: ImageSource, options?: Props);\n constructor(arg0: ImageSource | string, options?: Props) {\n super();\n this.filters = [];\n Object.assign(this, FabricImage.ownDefaults);\n this.setOptions(options);\n this.cacheKey = `texture${uid()}`;\n this.setElement(\n typeof arg0 === 'string'\n ? ((\n (this.canvas && getDocumentFromElement(this.canvas.getElement())) ||\n getFabricDocument()\n ).getElementById(arg0) as ImageSource)\n : arg0,\n options,\n );\n }\n\n /**\n * Returns image element which this instance if based on\n */\n getElement() {\n return this._element;\n }\n\n /**\n * Sets image element for this instance to a specified one.\n * If filters defined they are applied to new image.\n * You might need to call `canvas.renderAll` and `object.setCoords` after replacing, to render new image and update controls area.\n * @param {HTMLImageElement} element\n * @param {Partial} [size] Options object\n */\n setElement(element: ImageSource, size: Partial = {}) {\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._element = element;\n this._originalElement = element;\n this._setWidthHeight(size);\n element.classList.add(FabricImage.CSS_CANVAS);\n if (this.filters.length !== 0) {\n this.applyFilters();\n }\n // resizeFilters work on the already filtered copy.\n // we need to apply resizeFilters AFTER normal filters.\n // applyResizeFilters is run more often than normal filters\n // and is triggered by user interactions rather than dev code\n if (this.resizeFilter) {\n this.applyResizeFilters();\n }\n }\n\n /**\n * Delete a single texture if in webgl mode\n */\n removeTexture(key: string) {\n const backend = getFilterBackend(false);\n if (backend instanceof WebGLFilterBackend) {\n backend.evictCachesForKey(key);\n }\n }\n\n /**\n * Delete textures, reference to elements and eventually JSDOM cleanup\n */\n dispose() {\n super.dispose();\n this.removeTexture(this.cacheKey);\n this.removeTexture(`${this.cacheKey}_filtered`);\n this._cacheContext = null;\n (\n ['_originalElement', '_element', '_filteredEl', '_cacheCanvas'] as const\n ).forEach((elementKey) => {\n const el = this[elementKey];\n el && getEnv().dispose(el);\n // @ts-expect-error disposing\n this[elementKey] = undefined;\n });\n }\n\n /**\n * Get the crossOrigin value (of the corresponding image element)\n */\n getCrossOrigin(): string | null {\n return (\n this._originalElement &&\n ((this._originalElement as any).crossOrigin || null)\n );\n }\n\n /**\n * Returns original size of an image\n */\n getOriginalSize() {\n const element = this.getElement() as any;\n if (!element) {\n return {\n width: 0,\n height: 0,\n };\n }\n return {\n width: element.naturalWidth || element.width,\n height: element.naturalHeight || element.height,\n };\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _stroke(ctx: CanvasRenderingContext2D) {\n if (!this.stroke || this.strokeWidth === 0) {\n return;\n }\n const w = this.width / 2,\n h = this.height / 2;\n ctx.beginPath();\n ctx.moveTo(-w, -h);\n ctx.lineTo(w, -h);\n ctx.lineTo(w, h);\n ctx.lineTo(-w, h);\n ctx.lineTo(-w, -h);\n ctx.closePath();\n }\n\n /**\n * Returns object representation of an instance\n * @param {Array} [propertiesToInclude] Any properties that you might want to additionally include in the output\n * @return {Object} Object representation of an instance\n */\n toObject<\n T extends Omit, keyof SProps>,\n K extends keyof T = never,\n >(propertiesToInclude: K[] = []): Pick & SProps {\n const filters: Record[] = [];\n this.filters.forEach((filterObj) => {\n filterObj && filters.push(filterObj.toObject());\n });\n return {\n ...super.toObject([...IMAGE_PROPS, ...propertiesToInclude]),\n src: this.getSrc(),\n crossOrigin: this.getCrossOrigin(),\n filters,\n ...(this.resizeFilter\n ? { resizeFilter: this.resizeFilter.toObject() }\n : {}),\n };\n }\n\n /**\n * Returns true if an image has crop applied, inspecting values of cropX,cropY,width,height.\n * @return {Boolean}\n */\n hasCrop() {\n return (\n !!this.cropX ||\n !!this.cropY ||\n this.width < this._element.width ||\n this.height < this._element.height\n );\n }\n\n /**\n * Returns svg representation of an instance\n * @return {string[]} an array of strings with the specific svg representation\n * of the instance\n */\n _toSVG() {\n const imageMarkup: string[] = [],\n element = this._element,\n x = -this.width / 2,\n y = -this.height / 2;\n let svgString: string[] = [],\n strokeSvg: string[] = [],\n clipPath = '',\n imageRendering = '';\n if (!element) {\n return [];\n }\n if (this.hasCrop()) {\n const clipPathId = uid();\n svgString.push(\n '\\n',\n '\\t\\n',\n '\\n',\n );\n clipPath = ' clip-path=\"url(#imageCrop_' + clipPathId + ')\" ';\n }\n if (!this.imageSmoothing) {\n imageRendering = ' image-rendering=\"optimizeSpeed\"';\n }\n imageMarkup.push(\n '\\t element with actual transformation, then offsetting object to the top/left\n // so that object's center aligns with container's left/top\n }\" width=\"${\n element.width || (element as HTMLImageElement).naturalWidth\n }\" height=\"${\n element.height || (element as HTMLImageElement).naturalHeight\n }\"${imageRendering}${clipPath}>\\n`,\n );\n\n if (this.stroke || this.strokeDashArray) {\n const origFill = this.fill;\n this.fill = null;\n strokeSvg = [\n `\\t\\n`,\n ];\n this.fill = origFill;\n }\n if (this.paintFirst !== FILL) {\n svgString = svgString.concat(strokeSvg, imageMarkup);\n } else {\n svgString = svgString.concat(imageMarkup, strokeSvg);\n }\n return svgString;\n }\n\n /**\n * Returns source of an image\n * @param {Boolean} filtered indicates if the src is needed for svg\n * @return {String} Source of an image\n */\n getSrc(filtered?: boolean): string {\n const element = filtered ? this._element : this._originalElement;\n if (element) {\n if ((element as HTMLCanvasElement).toDataURL) {\n return (element as HTMLCanvasElement).toDataURL();\n }\n\n if (this.srcFromAttribute) {\n return element.getAttribute('src') || '';\n } else {\n return (element as HTMLImageElement).src;\n }\n } else {\n return this.src || '';\n }\n }\n\n /**\n * Alias for getSrc\n * @param filtered\n * @deprecated\n */\n getSvgSrc(filtered?: boolean) {\n return this.getSrc(filtered);\n }\n\n /**\n * Loads and sets source of an image\\\n * **IMPORTANT**: It is recommended to abort loading tasks before calling this method to prevent race conditions and unnecessary networking\n * @param {String} src Source string (URL)\n * @param {LoadImageOptions} [options] Options object\n */\n setSrc(src: string, { crossOrigin, signal }: LoadImageOptions = {}) {\n return loadImage(src, { crossOrigin, signal }).then((img) => {\n typeof crossOrigin !== 'undefined' && this.set({ crossOrigin });\n this.setElement(img);\n });\n }\n\n /**\n * Returns string representation of an instance\n * @return {String} String representation of an instance\n */\n toString() {\n return `#`;\n }\n\n applyResizeFilters() {\n const filter = this.resizeFilter,\n minimumScale = this.minimumScaleTrigger,\n objectScale = this.getTotalObjectScaling(),\n scaleX = objectScale.x,\n scaleY = objectScale.y,\n elementToFilter = this._filteredEl || this._originalElement;\n if (this.group) {\n this.set('dirty', true);\n }\n if (!filter || (scaleX > minimumScale && scaleY > minimumScale)) {\n this._element = elementToFilter;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n this._lastScaleX = scaleX;\n this._lastScaleY = scaleY;\n return;\n }\n const canvasEl = createCanvasElementFor(elementToFilter),\n { width, height } = elementToFilter;\n this._element = canvasEl;\n this._lastScaleX = filter.scaleX = scaleX;\n this._lastScaleY = filter.scaleY = scaleY;\n getFilterBackend().applyFilters(\n [filter],\n elementToFilter,\n width,\n height,\n this._element,\n );\n this._filterScalingX = canvasEl.width / this._originalElement.width;\n this._filterScalingY = canvasEl.height / this._originalElement.height;\n }\n\n /**\n * Applies filters assigned to this image (from \"filters\" array) or from filter param\n * @method applyFilters\n * @param {Array} filters to be applied\n * @param {Boolean} forResizing specify if the filter operation is a resize operation\n */\n applyFilters(\n filters: BaseFilter>[] = this.filters || [],\n ) {\n filters = filters.filter((filter) => filter && !filter.isNeutralState());\n this.set('dirty', true);\n\n // needs to clear out or WEBGL will not resize correctly\n this.removeTexture(`${this.cacheKey}_filtered`);\n\n if (filters.length === 0) {\n this._element = this._originalElement;\n // this is unsafe and needs to be rethinkend\n this._filteredEl = undefined;\n this._filterScalingX = 1;\n this._filterScalingY = 1;\n return;\n }\n\n const imgElement = this._originalElement,\n sourceWidth =\n (imgElement as HTMLImageElement).naturalWidth || imgElement.width,\n sourceHeight =\n (imgElement as HTMLImageElement).naturalHeight || imgElement.height;\n\n if (this._element === this._originalElement) {\n // if the _element a reference to _originalElement\n // we need to create a new element to host the filtered pixels\n const canvasEl = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n this._element = canvasEl;\n this._filteredEl = canvasEl;\n } else if (this._filteredEl) {\n // if the _element is it own element,\n // and we also have a _filteredEl, then we clean up _filteredEl\n // and we assign it to _element.\n // in this way we invalidate the eventual old resize filtered element\n this._element = this._filteredEl;\n this._filteredEl\n .getContext('2d')!\n .clearRect(0, 0, sourceWidth, sourceHeight);\n // we also need to resize again at next renderAll, so remove saved _lastScaleX/Y\n this._lastScaleX = 1;\n this._lastScaleY = 1;\n }\n getFilterBackend().applyFilters(\n filters,\n this._originalElement,\n sourceWidth,\n sourceHeight,\n this._element as HTMLCanvasElement,\n );\n if (\n this._originalElement.width !== this._element.width ||\n this._originalElement.height !== this._element.height\n ) {\n this._filterScalingX = this._element.width / this._originalElement.width;\n this._filterScalingY =\n this._element.height / this._originalElement.height;\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n _render(ctx: CanvasRenderingContext2D) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n if (this.isMoving !== true && this.resizeFilter && this._needsResize()) {\n this.applyResizeFilters();\n }\n this._stroke(ctx);\n this._renderPaintInOrder(ctx);\n }\n\n /**\n * Paint the cached copy of the object on the target context.\n * it will set the imageSmoothing for the draw operation\n * @param {CanvasRenderingContext2D} ctx Context to render on\n */\n drawCacheOnCanvas(\n this: TCachedFabricObject,\n ctx: CanvasRenderingContext2D,\n ) {\n ctx.imageSmoothingEnabled = this.imageSmoothing;\n super.drawCacheOnCanvas(ctx);\n }\n\n /**\n * Decide if the object should cache or not. Create its own cache level\n * needsItsOwnCache should be used when the object drawing method requires\n * a cache step. None of the fabric classes requires it.\n * Generally you do not cache objects in groups because the group outside is cached.\n * This is the special image version where we would like to avoid caching where possible.\n * Essentially images do not benefit from caching. They may require caching, and in that\n * case we do it. Also caching an image usually ends in a loss of details.\n * A full performance audit should be done.\n * @return {Boolean}\n */\n shouldCache() {\n return this.needsItsOwnCache();\n }\n\n _renderFill(ctx: CanvasRenderingContext2D) {\n const elementToDraw = this._element;\n if (!elementToDraw) {\n return;\n }\n const scaleX = this._filterScalingX,\n scaleY = this._filterScalingY,\n w = this.width,\n h = this.height,\n // crop values cannot be lesser than 0.\n cropX = Math.max(this.cropX, 0),\n cropY = Math.max(this.cropY, 0),\n elWidth =\n (elementToDraw as HTMLImageElement).naturalWidth || elementToDraw.width,\n elHeight =\n (elementToDraw as HTMLImageElement).naturalHeight ||\n elementToDraw.height,\n sX = cropX * scaleX,\n sY = cropY * scaleY,\n // the width height cannot exceed element width/height, starting from the crop offset.\n sW = Math.min(w * scaleX, elWidth - sX),\n sH = Math.min(h * scaleY, elHeight - sY),\n x = -w / 2,\n y = -h / 2,\n maxDestW = Math.min(w, elWidth / scaleX - cropX),\n maxDestH = Math.min(h, elHeight / scaleY - cropY);\n\n elementToDraw &&\n ctx.drawImage(elementToDraw, sX, sY, sW, sH, x, y, maxDestW, maxDestH);\n }\n\n /**\n * needed to check if image needs resize\n * @private\n */\n _needsResize() {\n const scale = this.getTotalObjectScaling();\n return scale.x !== this._lastScaleX || scale.y !== this._lastScaleY;\n }\n\n /**\n * @private\n * @deprecated unused\n */\n _resetWidthHeight() {\n this.set(this.getOriginalSize());\n }\n\n /**\n * @private\n * Set the width and the height of the image object, using the element or the\n * options.\n */\n _setWidthHeight({ width, height }: Partial = {}) {\n const size = this.getOriginalSize();\n this.width = width || size.width;\n this.height = height || size.height;\n }\n\n /**\n * Calculate offset for center and scale factor for the image in order to respect\n * the preserveAspectRatio attribute\n * @private\n */\n parsePreserveAspectRatioAttribute() {\n const pAR = parsePreserveAspectRatioAttribute(\n this.preserveAspectRatio || '',\n ),\n pWidth = this.width,\n pHeight = this.height,\n parsedAttributes = { width: pWidth, height: pHeight };\n let rWidth = this._element.width,\n rHeight = this._element.height,\n scaleX = 1,\n scaleY = 1,\n offsetLeft = 0,\n offsetTop = 0,\n cropX = 0,\n cropY = 0,\n offset;\n\n if (pAR && (pAR.alignX !== NONE || pAR.alignY !== NONE)) {\n if (pAR.meetOrSlice === 'meet') {\n scaleX = scaleY = findScaleToFit(this._element, parsedAttributes);\n offset = (pWidth - rWidth * scaleX) / 2;\n if (pAR.alignX === 'Min') {\n offsetLeft = -offset;\n }\n if (pAR.alignX === 'Max') {\n offsetLeft = offset;\n }\n offset = (pHeight - rHeight * scaleY) / 2;\n if (pAR.alignY === 'Min') {\n offsetTop = -offset;\n }\n if (pAR.alignY === 'Max') {\n offsetTop = offset;\n }\n }\n if (pAR.meetOrSlice === 'slice') {\n scaleX = scaleY = findScaleToCover(this._element, parsedAttributes);\n offset = rWidth - pWidth / scaleX;\n if (pAR.alignX === 'Mid') {\n cropX = offset / 2;\n }\n if (pAR.alignX === 'Max') {\n cropX = offset;\n }\n offset = rHeight - pHeight / scaleY;\n if (pAR.alignY === 'Mid') {\n cropY = offset / 2;\n }\n if (pAR.alignY === 'Max') {\n cropY = offset;\n }\n rWidth = pWidth / scaleX;\n rHeight = pHeight / scaleY;\n }\n } else {\n scaleX = pWidth / rWidth;\n scaleY = pHeight / rHeight;\n }\n return {\n width: rWidth,\n height: rHeight,\n scaleX,\n scaleY,\n offsetLeft,\n offsetTop,\n cropX,\n cropY,\n };\n }\n\n /**\n * Default CSS class name for canvas\n * @static\n * @type String\n * @default\n */\n static CSS_CANVAS = 'canvas-img';\n\n /**\n * List of attribute names to account for when parsing SVG element (used by {@link FabricImage.fromElement})\n * @static\n * @see {@link http://www.w3.org/TR/SVG/struct.html#ImageElement}\n */\n static ATTRIBUTE_NAMES = [\n ...SHARED_ATTRIBUTES,\n 'x',\n 'y',\n 'width',\n 'height',\n 'preserveAspectRatio',\n 'xlink:href',\n 'crossOrigin',\n 'image-rendering',\n ];\n\n /**\n * Creates an instance of FabricImage from its object representation\n * @static\n * @param {Object} object Object to create an instance from\n * @param {object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject>(\n { filters: f, resizeFilter: rf, src, crossOrigin, type, ...object }: T,\n options?: Abortable,\n ) {\n return Promise.all([\n loadImage(src!, { ...options, crossOrigin }),\n f && enlivenObjects>(f, options),\n // TODO: redundant - handled by enlivenObjectEnlivables\n rf && enlivenObjects>([rf], options),\n enlivenObjectEnlivables(object, options),\n ]).then(([el, filters = [], [resizeFilter] = [], hydratedProps = {}]) => {\n return new this(el, {\n ...object,\n // TODO: this creates a difference between image creation and restoring from JSON\n src,\n filters,\n resizeFilter,\n ...hydratedProps,\n });\n });\n }\n\n /**\n * Creates an instance of Image from an URL string\n * @static\n * @param {String} url URL to create an image from\n * @param {LoadImageOptions} [options] Options object\n * @returns {Promise}\n */\n static fromURL>(\n url: string,\n { crossOrigin = null, signal }: LoadImageOptions = {},\n imageOptions?: T,\n ): Promise {\n return loadImage(url, { crossOrigin, signal }).then(\n (img) => new this(img, imageOptions),\n );\n }\n\n /**\n * Returns {@link FabricImage} instance from an SVG element\n * @static\n * @param {HTMLElement} element Element to parse\n * @param {Object} [options] Options object\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @param {Function} callback Callback to execute when Image object is created\n */\n static async fromElement(\n element: HTMLElement,\n options: Abortable = {},\n cssRules?: CSSRules,\n ) {\n const parsedAttributes = parseAttributes(\n element,\n this.ATTRIBUTE_NAMES,\n cssRules,\n );\n return this.fromURL(\n parsedAttributes['xlink:href'],\n options,\n parsedAttributes,\n ).catch((err) => {\n log('log', 'Unable to parse Image', err);\n return null;\n });\n }\n}\n\nclassRegistry.setClass(FabricImage);\nclassRegistry.setSVGClass(FabricImage);\n","import { svgNS } from './constants';\nimport {\n parsePreserveAspectRatioAttribute,\n parseUnit,\n} from '../util/misc/svgParsing';\nimport { svgViewBoxElementsRegEx, reViewBoxAttrValue } from './constants';\nimport { NONE } from '../constants';\n\nexport type ParsedViewboxTransform = Partial<{\n width: number;\n height: number;\n minX: number;\n minY: number;\n viewBoxWidth: number;\n viewBoxHeight: number;\n}>;\n\n/**\n * Add a element that envelop all child elements and makes the viewbox transformMatrix descend on all elements\n */\nexport function applyViewboxTransform(\n element: Element,\n): ParsedViewboxTransform {\n if (!svgViewBoxElementsRegEx.test(element.nodeName)) {\n return {};\n }\n const viewBoxAttr: string | null = element.getAttribute('viewBox');\n let scaleX = 1;\n let scaleY = 1;\n let minX = 0;\n let minY = 0;\n let matrix;\n let el;\n const widthAttr = element.getAttribute('width');\n const heightAttr = element.getAttribute('height');\n const x = element.getAttribute('x') || 0;\n const y = element.getAttribute('y') || 0;\n const goodViewbox = viewBoxAttr && reViewBoxAttrValue.test(viewBoxAttr);\n const missingViewBox = !goodViewbox;\n const missingDimAttr =\n !widthAttr || !heightAttr || widthAttr === '100%' || heightAttr === '100%';\n\n let translateMatrix = '';\n let widthDiff = 0;\n let heightDiff = 0;\n\n if (missingViewBox) {\n if (\n (x || y) &&\n element.parentNode &&\n element.parentNode.nodeName !== '#document'\n ) {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n matrix = (element.getAttribute('transform') || '') + translateMatrix;\n element.setAttribute('transform', matrix);\n element.removeAttribute('x');\n element.removeAttribute('y');\n }\n }\n\n if (missingViewBox && missingDimAttr) {\n return {\n width: 0,\n height: 0,\n };\n }\n\n const parsedDim: ParsedViewboxTransform = {\n width: 0,\n height: 0,\n };\n\n if (missingViewBox) {\n parsedDim.width = parseUnit(widthAttr!);\n parsedDim.height = parseUnit(heightAttr!);\n // set a transform for elements that have x y and are inner(only) SVGs\n return parsedDim;\n }\n\n const pasedViewBox = viewBoxAttr.match(reViewBoxAttrValue)!;\n minX = -parseFloat(pasedViewBox[1]);\n minY = -parseFloat(pasedViewBox[2]);\n const viewBoxWidth = parseFloat(pasedViewBox[3]);\n const viewBoxHeight = parseFloat(pasedViewBox[4]);\n parsedDim.minX = minX;\n parsedDim.minY = minY;\n parsedDim.viewBoxWidth = viewBoxWidth;\n parsedDim.viewBoxHeight = viewBoxHeight;\n if (!missingDimAttr) {\n parsedDim.width = parseUnit(widthAttr);\n parsedDim.height = parseUnit(heightAttr);\n scaleX = parsedDim.width / viewBoxWidth;\n scaleY = parsedDim.height / viewBoxHeight;\n } else {\n parsedDim.width = viewBoxWidth;\n parsedDim.height = viewBoxHeight;\n }\n\n // default is to preserve aspect ratio\n const preserveAspectRatio = parsePreserveAspectRatioAttribute(\n element.getAttribute('preserveAspectRatio') || '',\n );\n if (preserveAspectRatio.alignX !== NONE) {\n //translate all container for the effect of Mid, Min, Max\n if (preserveAspectRatio.meetOrSlice === 'meet') {\n scaleY = scaleX = scaleX > scaleY ? scaleY : scaleX;\n // calculate additional translation to move the viewbox\n }\n if (preserveAspectRatio.meetOrSlice === 'slice') {\n scaleY = scaleX = scaleX > scaleY ? scaleX : scaleY;\n // calculate additional translation to move the viewbox\n }\n widthDiff = parsedDim.width - viewBoxWidth * scaleX;\n heightDiff = parsedDim.height - viewBoxHeight * scaleX;\n if (preserveAspectRatio.alignX === 'Mid') {\n widthDiff /= 2;\n }\n if (preserveAspectRatio.alignY === 'Mid') {\n heightDiff /= 2;\n }\n if (preserveAspectRatio.alignX === 'Min') {\n widthDiff = 0;\n }\n if (preserveAspectRatio.alignY === 'Min') {\n heightDiff = 0;\n }\n }\n\n if (\n scaleX === 1 &&\n scaleY === 1 &&\n minX === 0 &&\n minY === 0 &&\n x === 0 &&\n y === 0\n ) {\n return parsedDim;\n }\n if ((x || y) && element.parentNode!.nodeName !== '#document') {\n translateMatrix =\n ' translate(' + parseUnit(x || '0') + ' ' + parseUnit(y || '0') + ') ';\n }\n\n matrix =\n translateMatrix +\n ' matrix(' +\n scaleX +\n ' 0' +\n ' 0 ' +\n scaleY +\n ' ' +\n (minX * scaleX + widthDiff) +\n ' ' +\n (minY * scaleY + heightDiff) +\n ') ';\n // seems unused.\n // parsedDim.viewboxTransform = parseTransformAttribute(matrix);\n if (element.nodeName === 'svg') {\n el = element.ownerDocument.createElementNS(svgNS, 'g');\n // element.firstChild != null\n while (element.firstChild) {\n el.appendChild(element.firstChild);\n }\n element.appendChild(el);\n } else {\n el = element;\n el.removeAttribute('x');\n el.removeAttribute('y');\n matrix = el.getAttribute('transform') + matrix;\n }\n el.setAttribute('transform', matrix);\n return parsedDim;\n}\n","export const getTagName = (node: Element) => node.tagName.replace('svg:', '');\n","import { svgInvalidAncestors } from './constants';\nimport { getSvgRegex } from './getSvgRegex';\nimport { getTagName } from './getTagName';\n\nconst svgInvalidAncestorsRegEx = getSvgRegex(svgInvalidAncestors);\n\nexport function hasInvalidAncestor(element: Element) {\n let _element: Element | null = element;\n while (_element && (_element = _element.parentElement)) {\n if (\n _element &&\n _element.nodeName &&\n svgInvalidAncestorsRegEx.test(getTagName(_element)) &&\n !_element.getAttribute('instantiated_by_use')\n ) {\n return true;\n }\n }\n return false;\n}\n","export function getMultipleNodes(\n doc: Document,\n nodeNames: string[],\n): Element[] {\n let nodeName,\n nodeArray: Element[] = [],\n nodeList,\n i,\n len;\n for (i = 0, len = nodeNames.length; i < len; i++) {\n nodeName = nodeNames[i];\n nodeList = doc.getElementsByTagNameNS(\n 'http://www.w3.org/2000/svg',\n nodeName,\n );\n nodeArray = nodeArray.concat(Array.from(nodeList));\n }\n return nodeArray;\n}\n","import { svgNS } from './constants';\nimport { getMultipleNodes } from './getMultipleNodes';\nimport { applyViewboxTransform } from './applyViewboxTransform';\nimport { parseStyleString } from './parseStyleString';\n\nexport function parseUseDirectives(doc: Document) {\n const nodelist = getMultipleNodes(doc, ['use', 'svg:use']);\n const skipAttributes = ['x', 'y', 'xlink:href', 'href', 'transform'];\n\n for (const useElement of nodelist) {\n const useAttributes: NamedNodeMap = useElement.attributes;\n\n const useAttrMap: Record = {};\n for (const attr of useAttributes) {\n attr.value && (useAttrMap[attr.name] = attr.value);\n }\n\n const xlink = (useAttrMap['xlink:href'] || useAttrMap.href || '').slice(1);\n\n if (xlink === '') {\n return;\n }\n const referencedElement = doc.getElementById(xlink);\n if (referencedElement === null) {\n // if we can't find the target of the xlink, consider this use tag bad, similar to no xlink\n return;\n }\n let clonedOriginal = referencedElement.cloneNode(true) as Element;\n\n const originalAttributes: NamedNodeMap = clonedOriginal.attributes;\n\n const originalAttrMap: Record = {};\n for (const attr of originalAttributes) {\n attr.value && (originalAttrMap[attr.name] = attr.value);\n }\n\n // Transform attribute needs to be merged in a particular way\n const { x = 0, y = 0, transform = '' } = useAttrMap;\n const currentTrans = `${transform} ${\n originalAttrMap.transform || ''\n } translate(${x}, ${y})`;\n\n applyViewboxTransform(clonedOriginal);\n\n if (/^svg$/i.test(clonedOriginal.nodeName)) {\n // if is an SVG, create a group and apply all the attributes on top of it\n const el3 = clonedOriginal.ownerDocument.createElementNS(svgNS, 'g');\n Object.entries(originalAttrMap).forEach(([name, value]) =>\n el3.setAttributeNS(svgNS, name, value),\n );\n el3.append(...clonedOriginal.childNodes);\n clonedOriginal = el3;\n }\n\n for (const attr of useAttributes) {\n if (!attr) {\n continue;\n }\n const { name, value } = attr;\n if (skipAttributes.includes(name)) {\n continue;\n }\n\n if (name === 'style') {\n // when use has a style, merge the two styles, with the ref being priority (not use)\n // priority is by feature. an attribute for fill on the original element\n // will overwrite the fill in style or attribute for tha use\n const styleRecord: Record = {};\n parseStyleString(value!, styleRecord);\n // cleanup styleRecord from attributes of original\n Object.entries(originalAttrMap).forEach(([name, value]) => {\n styleRecord[name] = value;\n });\n // now we can put in the style of the original that will overwrite the original attributes\n parseStyleString(originalAttrMap.style || '', styleRecord);\n const mergedStyles = Object.entries(styleRecord)\n .map((entry) => entry.join(':'))\n .join(';');\n clonedOriginal.setAttribute(name, mergedStyles);\n } else {\n // set the attribute from use element only if the original does not have it already\n !originalAttrMap[name] && clonedOriginal.setAttribute(name, value!);\n }\n }\n\n clonedOriginal.setAttribute('transform', currentTrans);\n clonedOriginal.setAttribute('instantiated_by_use', '1');\n clonedOriginal.removeAttribute('id');\n useElement.parentNode!.replaceChild(clonedOriginal, useElement);\n }\n}\n","const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n","import { getMultipleNodes } from './getMultipleNodes';\nimport { recursivelyParseGradientsXlink } from './recursivelyParseGradientsXlink';\n\nconst tagArray = [\n 'linearGradient',\n 'radialGradient',\n 'svg:linearGradient',\n 'svg:radialGradient',\n];\n\n/**\n * Parses an SVG document, returning all of the gradient declarations found in it\n * @param {SVGDocument} doc SVG document to parse\n * @return {Object} Gradient definitions; key corresponds to element id, value -- to gradient definition element\n */\nexport function getGradientDefs(\n doc: Document,\n): Record {\n const elList = getMultipleNodes(doc, tagArray);\n const gradientDefs: Record = {};\n let j = elList.length;\n while (j--) {\n const el = elList[j];\n if (el.getAttribute('xlink:href')) {\n recursivelyParseGradientsXlink(doc, el);\n }\n const id = el.getAttribute('id');\n if (id) {\n gradientDefs[id] = el as SVGGradientElement;\n }\n }\n return gradientDefs;\n}\n","import type { CSSRules } from './typedefs';\n\n/**\n * Returns CSS rules for a given SVG document\n * @param {HTMLElement} doc SVG document to parse\n * @return {Object} CSS rules of this document\n */\nexport function getCSSRules(doc: Document) {\n const styles = doc.getElementsByTagName('style');\n let i;\n let len;\n const allRules: CSSRules = {};\n\n // very crude parsing of style contents\n for (i = 0, len = styles.length; i < len; i++) {\n const styleContents = (styles[i].textContent || '').replace(\n // remove comments\n /\\/\\*[\\s\\S]*?\\*\\//g,\n '',\n );\n\n if (styleContents.trim() === '') {\n continue;\n }\n // recovers all the rule in this form `body { style code... }`\n // rules = styleContents.match(/[^{]*\\{[\\s\\S]*?\\}/g);\n styleContents\n .split('}')\n // remove empty rules and remove everything if we didn't split in at least 2 pieces\n .filter((rule, index, array) => array.length > 1 && rule.trim())\n // at this point we have hopefully an array of rules `body { style code... `\n .forEach((rule) => {\n // if there is more than one opening bracket and the rule starts with '@', it is likely\n // a nested at-rule like @media, @supports, @scope, etc. Ignore these as the code below\n // can not handle it.\n if (\n (rule.match(/{/g) || []).length > 1 &&\n rule.trim().startsWith('@')\n ) {\n return;\n }\n\n const match = rule.split('{'),\n ruleObj: Record = {},\n declaration = match[1].trim(),\n propertyValuePairs = declaration.split(';').filter(function (pair) {\n return pair.trim();\n });\n\n for (i = 0, len = propertyValuePairs.length; i < len; i++) {\n const pair = propertyValuePairs[i].split(':'),\n property = pair[0].trim(),\n value = pair[1].trim();\n ruleObj[property] = value;\n }\n rule = match[0].trim();\n rule.split(',').forEach((_rule) => {\n _rule = _rule.replace(/^svg/i, '').trim();\n if (_rule === '') {\n return;\n }\n allRules[_rule] = {\n ...(allRules[_rule] || {}),\n ...ruleObj,\n };\n });\n });\n }\n return allRules;\n}\n","import { Gradient } from '../gradient/Gradient';\nimport { Group } from '../shapes/Group';\nimport { FabricImage } from '../shapes/Image';\nimport { classRegistry } from '../ClassRegistry';\nimport {\n invertTransform,\n multiplyTransformMatrices,\n qrDecompose,\n} from '../util/misc/matrix';\nimport { removeTransformMatrixForSvgParsing } from '../util/transform_matrix_removal';\nimport type { FabricObject } from '../shapes/Object/FabricObject';\nimport { Point } from '../Point';\nimport { CENTER, FILL, STROKE } from '../constants';\nimport { getGradientDefs } from './getGradientDefs';\nimport { getCSSRules } from './getCSSRules';\nimport type { LoadImageOptions } from '../util';\nimport type { CSSRules, TSvgReviverCallback } from './typedefs';\nimport type { ParsedViewboxTransform } from './applyViewboxTransform';\nimport type { SVGOptions } from '../gradient';\nimport { getTagName } from './getTagName';\nimport { parseTransformAttribute } from './parseTransformAttribute';\n\nconst findTag = (el: Element) =>\n classRegistry.getSVGClass(getTagName(el).toLowerCase());\n\ntype StorageType = {\n fill: SVGGradientElement;\n stroke: SVGGradientElement;\n clipPath: Element[];\n};\n\ntype NotParsedFabricObject = FabricObject & {\n fill: string;\n stroke: string;\n clipPath?: string;\n clipRule?: CanvasFillRule;\n};\n\nexport class ElementsParser {\n declare elements: Element[];\n declare options: LoadImageOptions & ParsedViewboxTransform;\n declare reviver?: TSvgReviverCallback;\n declare regexUrl: RegExp;\n declare doc: Document;\n declare clipPaths: Record;\n declare gradientDefs: Record;\n declare cssRules: CSSRules;\n\n constructor(\n elements: Element[],\n options: LoadImageOptions & ParsedViewboxTransform,\n reviver: TSvgReviverCallback | undefined,\n doc: Document,\n clipPaths: Record,\n ) {\n this.elements = elements;\n this.options = options;\n this.reviver = reviver;\n this.regexUrl = /^url\\(['\"]?#([^'\"]+)['\"]?\\)/g;\n this.doc = doc;\n this.clipPaths = clipPaths;\n this.gradientDefs = getGradientDefs(doc);\n this.cssRules = getCSSRules(doc);\n }\n\n parse(): Promise> {\n return Promise.all(\n this.elements.map((element) => this.createObject(element)),\n );\n }\n\n async createObject(el: Element): Promise {\n const klass = findTag(el);\n if (klass) {\n const obj: NotParsedFabricObject = await klass.fromElement(\n el,\n this.options,\n this.cssRules,\n );\n this.resolveGradient(obj, el, FILL);\n this.resolveGradient(obj, el, STROKE);\n if (obj instanceof FabricImage && obj._originalElement) {\n removeTransformMatrixForSvgParsing(\n obj,\n obj.parsePreserveAspectRatioAttribute(),\n );\n } else {\n removeTransformMatrixForSvgParsing(obj);\n }\n await this.resolveClipPath(obj, el);\n this.reviver && this.reviver(el, obj);\n return obj;\n }\n return null;\n }\n\n extractPropertyDefinition(\n obj: NotParsedFabricObject,\n property: 'fill' | 'stroke' | 'clipPath',\n storage: Record,\n ): StorageType[typeof property] | undefined {\n const value = obj[property]!,\n regex = this.regexUrl;\n if (!regex.test(value)) {\n return undefined;\n }\n // verify: can we remove the 'g' flag? and remove lastIndex changes?\n regex.lastIndex = 0;\n // we passed the regex test, so we know is not null;\n const id = regex.exec(value)![1];\n regex.lastIndex = 0;\n // @todo fix this\n return storage[id];\n }\n\n resolveGradient(\n obj: NotParsedFabricObject,\n el: Element,\n property: 'fill' | 'stroke',\n ) {\n const gradientDef = this.extractPropertyDefinition(\n obj,\n property,\n this.gradientDefs,\n ) as SVGGradientElement;\n if (gradientDef) {\n const opacityAttr = el.getAttribute(property + '-opacity');\n const gradient = Gradient.fromElement(gradientDef, obj, {\n ...this.options,\n opacity: opacityAttr,\n } as SVGOptions);\n obj.set(property, gradient);\n }\n }\n\n // TODO: resolveClipPath could be run once per clippath with minor work per object.\n // is a refactor that i m not sure is worth on this code\n async resolveClipPath(\n obj: NotParsedFabricObject,\n usingElement: Element,\n exactOwner?: Element,\n ) {\n const clipPathElements = this.extractPropertyDefinition(\n obj,\n 'clipPath',\n this.clipPaths,\n ) as Element[];\n if (clipPathElements) {\n const objTransformInv = invertTransform(obj.calcTransformMatrix());\n const clipPathTag = clipPathElements[0].parentElement!;\n let clipPathOwner = usingElement;\n while (\n !exactOwner &&\n clipPathOwner.parentElement &&\n clipPathOwner.getAttribute('clip-path') !== obj.clipPath\n ) {\n clipPathOwner = clipPathOwner.parentElement;\n }\n // move the clipPath tag as sibling to the real element that is using it\n clipPathOwner.parentElement!.appendChild(clipPathTag!);\n\n // this multiplication order could be opposite.\n // but i don't have an svg to test it\n // at the first SVG that has a transform on both places and is misplaced\n // try to invert this multiplication order\n const finalTransform = parseTransformAttribute(\n `${clipPathOwner.getAttribute('transform') || ''} ${\n clipPathTag.getAttribute('originalTransform') || ''\n }`,\n );\n\n clipPathTag.setAttribute(\n 'transform',\n `matrix(${finalTransform.join(',')})`,\n );\n\n const container = await Promise.all(\n clipPathElements.map((clipPathElement) => {\n return findTag(clipPathElement)\n .fromElement(clipPathElement, this.options, this.cssRules)\n .then((enlivedClippath: NotParsedFabricObject) => {\n removeTransformMatrixForSvgParsing(enlivedClippath);\n enlivedClippath.fillRule = enlivedClippath.clipRule!;\n delete enlivedClippath.clipRule;\n return enlivedClippath;\n });\n }),\n );\n const clipPath =\n container.length === 1 ? container[0] : new Group(container);\n const gTransform = multiplyTransformMatrices(\n objTransformInv,\n clipPath.calcTransformMatrix(),\n );\n if (clipPath.clipPath) {\n await this.resolveClipPath(\n clipPath,\n clipPathOwner,\n // this is tricky.\n // it tries to differentiate from when clipPaths are inherited by outside groups\n // or when are really clipPaths referencing other clipPaths\n clipPathTag.getAttribute('clip-path') ? clipPathOwner : undefined,\n );\n }\n const { scaleX, scaleY, angle, skewX, translateX, translateY } =\n qrDecompose(gTransform);\n clipPath.set({\n flipX: false,\n flipY: false,\n });\n clipPath.set({\n scaleX,\n scaleY,\n angle,\n skewX,\n skewY: 0,\n });\n clipPath.setPositionByOrigin(\n new Point(translateX, translateY),\n CENTER,\n CENTER,\n );\n obj.clipPath = clipPath;\n } else {\n // if clip-path does not resolve to any element, delete the property.\n delete obj.clipPath;\n return;\n }\n }\n}\n","import { applyViewboxTransform } from './applyViewboxTransform';\nimport { svgValidTagNamesRegEx } from './constants';\nimport { hasInvalidAncestor } from './hasInvalidAncestor';\nimport { parseUseDirectives } from './parseUseDirectives';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { ElementsParser } from './elements_parser';\nimport { log, SignalAbortedError } from '../util/internals/console';\nimport { getTagName } from './getTagName';\n\nconst isValidSvgTag = (el: Element) =>\n svgValidTagNamesRegEx.test(getTagName(el));\n\nexport const createEmptyResponse = (): SVGParsingOutput => ({\n objects: [],\n elements: [],\n options: {},\n allElements: [],\n});\n\n/**\n * Parses an SVG document, converts it to an array of corresponding fabric.* instances and passes them to a callback\n * @static\n * @function\n * @memberOf fabric\n * @param {HTMLElement} doc SVG document to parse\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @return {SVGParsingOutput}\n * {@link SVGParsingOutput} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n */\nexport async function parseSVGDocument(\n doc: Document,\n reviver?: TSvgReviverCallback,\n { crossOrigin, signal }: LoadImageOptions = {},\n): Promise {\n if (signal && signal.aborted) {\n log('log', new SignalAbortedError('parseSVGDocument'));\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n }\n const documentElement = doc.documentElement;\n parseUseDirectives(doc);\n\n const descendants = Array.from(documentElement.getElementsByTagName('*')),\n options = {\n ...applyViewboxTransform(documentElement),\n crossOrigin,\n signal,\n };\n const elements = descendants.filter((el) => {\n applyViewboxTransform(el);\n return isValidSvgTag(el) && !hasInvalidAncestor(el); // http://www.w3.org/TR/SVG/struct.html#DefsElement\n });\n if (!elements || (elements && !elements.length)) {\n return {\n ...createEmptyResponse(),\n options,\n allElements: descendants,\n };\n }\n const localClipPaths: Record = {};\n descendants\n .filter((el) => getTagName(el) === 'clipPath')\n .forEach((el) => {\n el.setAttribute('originalTransform', el.getAttribute('transform') || '');\n const id = el.getAttribute('id')!;\n localClipPaths[id] = Array.from(el.getElementsByTagName('*')).filter(\n (el) => isValidSvgTag(el),\n );\n });\n\n // Precedence of rules: style > class > attribute\n const elementParser = new ElementsParser(\n elements,\n options,\n reviver,\n doc,\n localClipPaths,\n );\n\n const instances = await elementParser.parse();\n\n return {\n objects: instances,\n elements,\n options,\n allElements: descendants,\n };\n}\n","import { getFabricWindow } from '../env';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\nimport { parseSVGDocument } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\n\n/**\n * Takes string corresponding to an SVG document, and parses it into a set of fabric objects\n * @memberOf fabric\n * @param {String} string representing the svg\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromString(\n string: string,\n reviver?: TSvgReviverCallback,\n options?: LoadImageOptions,\n): Promise {\n const parser = new (getFabricWindow().DOMParser)(),\n // should we use `image/svg+xml` here?\n doc = parser.parseFromString(string.trim(), 'text/xml');\n return parseSVGDocument(doc, reviver, options);\n}\n","import { request } from '../util/internals/dom_request';\nimport { parseSVGDocument, createEmptyResponse } from './parseSVGDocument';\nimport type { SVGParsingOutput, TSvgReviverCallback } from './typedefs';\nimport type { LoadImageOptions } from '../util/misc/objectEnlive';\n\n/**\n * Takes url corresponding to an SVG document, and parses it into a set of fabric objects.\n * Note that SVG is fetched via XMLHttpRequest, so it needs to conform to SOP (Same Origin Policy)\n * @memberOf fabric\n * @param {string} url where the SVG is\n * @param {TSvgParsedCallback} callback Invoked when the parsing is done, with null if parsing wasn't possible with the list of svg nodes.\n * {@link TSvgParsedCallback} also receives `allElements` array as the last argument. This is the full list of svg nodes available in the document.\n * You may want to use it if you are trying to regroup the objects as they were originally grouped in the SVG. ( This was the reason why it was added )\n * @param {TSvgReviverCallback} [reviver] Extra callback for further parsing of SVG elements, called after each fabric object has been created.\n * Takes as input the original svg element and the generated `FabricObject` as arguments. Used to inspect extra properties not parsed by fabric,\n * or extra custom manipulation\n * @param {Object} [options] Object containing options for parsing\n * @param {String} [options.crossOrigin] crossOrigin setting to use for external resources\n * @param {AbortSignal} [options.signal] handle aborting, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n */\nexport function loadSVGFromURL(\n url: string,\n reviver?: TSvgReviverCallback,\n options: LoadImageOptions = {},\n): Promise {\n // need to handle error properly\n return new Promise((resolve, reject) => {\n const onComplete = (r: XMLHttpRequest) => {\n const xml = r.responseXML;\n if (xml) {\n resolve(xml);\n }\n reject();\n };\n\n request(url.replace(/^\\n\\s*/, '').trim(), {\n onComplete,\n signal: options.signal,\n });\n })\n .then((parsedDoc) => parseSVGDocument(parsedDoc, reviver, options))\n .catch(() => {\n // this is an unhappy path, we dont care about speed\n return createEmptyResponse();\n });\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Polyline } from '../shapes/Polyline';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n TransformActionHandler,\n} from '../EventTypeDefs';\nimport { wrapWithFireEvent } from './wrapWithFireEvent';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport { MODIFY_POLY } from '../constants';\n\nconst ACTION_NAME: TModificationEvents = MODIFY_POLY;\n\ntype TTransformAnchor = Transform & { pointIndex: number };\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nexport const createPolyPositionHandler = (pointIndex: number) => {\n return function (dim: Point, finalMatrix: TMat2D, polyObject: Polyline) {\n const { points, pathOffset } = polyObject;\n return new Point(points[pointIndex])\n .subtract(pathOffset)\n .transform(\n multiplyTransformMatrices(\n polyObject.getViewportTransform(),\n polyObject.calcTransformMatrix(),\n ),\n );\n };\n};\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nexport const polyActionHandler = (\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) => {\n const { target, pointIndex } = transform;\n const poly = target as Polyline;\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n poly.calcOwnMatrix(),\n );\n\n poly.points[pointIndex] = mouseLocalPosition.add(poly.pathOffset);\n poly.setDimensions();\n\n return true;\n};\n\n/**\n * Keep the polygon in the same position when we change its `width`/`height`/`top`/`left`.\n */\nexport const factoryPolyActionHandler = (\n pointIndex: number,\n fn: TransformActionHandler,\n) => {\n return function (\n eventData: TPointerEvent,\n transform: Transform,\n x: number,\n y: number,\n ) {\n const poly = transform.target as Polyline,\n anchorPoint = new Point(\n poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1],\n ),\n anchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix()),\n actionPerformed = fn(eventData, { ...transform, pointIndex }, x, y);\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(poly.pathOffset)\n .transform(poly.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n poly.left -= diff.x;\n poly.top -= diff.y;\n\n return actionPerformed;\n };\n};\n\nexport const createPolyActionHandler = (pointIndex: number) =>\n wrapWithFireEvent(\n ACTION_NAME,\n factoryPolyActionHandler(pointIndex, polyActionHandler),\n );\n\nexport function createPolyControls(\n poly: Polyline,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n numOfControls: number,\n options?: Partial,\n): Record;\nexport function createPolyControls(\n arg0: number | Polyline,\n options: Partial = {},\n) {\n const controls = {} as Record;\n for (\n let idx = 0;\n idx < (typeof arg0 === 'number' ? arg0 : arg0.points.length);\n idx++\n ) {\n controls[`p${idx}`] = new Control({\n actionName: ACTION_NAME,\n positionHandler: createPolyPositionHandler(idx),\n actionHandler: createPolyActionHandler(idx),\n ...options,\n });\n }\n return controls;\n}\n","import { Point } from '../Point';\nimport { Control } from './Control';\nimport type { TMat2D } from '../typedefs';\nimport type { Path } from '../shapes/Path';\nimport { multiplyTransformMatrices } from '../util/misc/matrix';\nimport type {\n TModificationEvents,\n TPointerEvent,\n Transform,\n} from '../EventTypeDefs';\nimport { sendPointToPlane } from '../util/misc/planeChange';\nimport type { TSimpleParseCommandType } from '../util/path/typedefs';\nimport type { ControlRenderingStyleOverride } from './controlRendering';\nimport { fireEvent } from './fireEvent';\nimport { commonEventInfo } from './util';\n\nconst ACTION_NAME: TModificationEvents = 'modifyPath' as const;\n\ntype TTransformAnchor = Transform;\n\nexport type PathPointControlStyle = {\n controlFill?: string;\n controlStroke?: string;\n connectionDashArray?: number[];\n};\n\nconst calcPathPointPosition = (\n pathObject: Path,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n const command = path[commandIndex];\n return new Point(\n (command[pointIndex] as number) - pathOffset.x,\n (command[pointIndex + 1] as number) - pathOffset.y,\n ).transform(\n multiplyTransformMatrices(\n pathObject.getViewportTransform(),\n pathObject.calcTransformMatrix(),\n ),\n );\n};\n\nconst movePathPoint = (\n pathObject: Path,\n x: number,\n y: number,\n commandIndex: number,\n pointIndex: number,\n) => {\n const { path, pathOffset } = pathObject;\n\n const anchorCommand =\n path[(commandIndex > 0 ? commandIndex : path.length) - 1];\n const anchorPoint = new Point(\n anchorCommand[pointIndex] as number,\n anchorCommand[pointIndex + 1] as number,\n );\n\n const anchorPointInParentPlane = anchorPoint\n .subtract(pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const mouseLocalPosition = sendPointToPlane(\n new Point(x, y),\n undefined,\n pathObject.calcOwnMatrix(),\n );\n\n path[commandIndex][pointIndex] = mouseLocalPosition.x + pathOffset.x;\n path[commandIndex][pointIndex + 1] = mouseLocalPosition.y + pathOffset.y;\n pathObject.setDimensions();\n\n const newAnchorPointInParentPlane = anchorPoint\n .subtract(pathObject.pathOffset)\n .transform(pathObject.calcOwnMatrix());\n\n const diff = newAnchorPointInParentPlane.subtract(anchorPointInParentPlane);\n pathObject.left -= diff.x;\n pathObject.top -= diff.y;\n pathObject.set('dirty', true);\n return true;\n};\n\n/**\n * This function locates the controls.\n * It'll be used both for drawing and for interaction.\n */\nfunction pathPositionHandler(\n this: PathPointControl,\n dim: Point,\n finalMatrix: TMat2D,\n pathObject: Path,\n) {\n const { commandIndex, pointIndex } = this;\n return calcPathPointPosition(pathObject, commandIndex, pointIndex);\n}\n\n/**\n * This function defines what the control does.\n * It'll be called on every mouse move after a control has been clicked and is being dragged.\n * The function receives as argument the mouse event, the current transform object\n * and the current position in canvas coordinate `transform.target` is a reference to the\n * current object being transformed.\n */\nfunction pathActionHandler(\n this: PathPointControl,\n eventData: TPointerEvent,\n transform: TTransformAnchor,\n x: number,\n y: number,\n) {\n const { target } = transform;\n const { commandIndex, pointIndex } = this;\n const actionPerformed = movePathPoint(\n target as Path,\n x,\n y,\n commandIndex,\n pointIndex,\n );\n if (actionPerformed) {\n fireEvent(this.actionName as TModificationEvents, {\n ...commonEventInfo(eventData, transform, x, y),\n commandIndex,\n pointIndex,\n });\n }\n return actionPerformed;\n}\n\nconst indexFromPrevCommand = (previousCommandType: TSimpleParseCommandType) =>\n previousCommandType === 'C' ? 5 : previousCommandType === 'Q' ? 3 : 1;\n\nclass PathPointControl extends Control {\n declare commandIndex: number;\n declare pointIndex: number;\n declare controlFill: string;\n declare controlStroke: string;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const overrides: ControlRenderingStyleOverride = {\n ...styleOverride,\n cornerColor: this.controlFill,\n cornerStrokeColor: this.controlStroke,\n transparentCorners: !this.controlFill,\n };\n super.render(ctx, left, top, overrides, fabricObject);\n }\n}\n\nclass PathControlPointControl extends PathPointControl {\n declare connectionDashArray?: number[];\n declare connectToCommandIndex: number;\n declare connectToPointIndex: number;\n constructor(options?: Partial) {\n super(options);\n }\n\n render(\n this: PathControlPointControl,\n ctx: CanvasRenderingContext2D,\n left: number,\n top: number,\n styleOverride: ControlRenderingStyleOverride | undefined,\n fabricObject: Path,\n ) {\n const { path } = fabricObject;\n const {\n commandIndex,\n pointIndex,\n connectToCommandIndex,\n connectToPointIndex,\n } = this;\n ctx.save();\n ctx.strokeStyle = this.controlStroke;\n if (this.connectionDashArray) {\n ctx.setLineDash(this.connectionDashArray);\n }\n const [commandType] = path[commandIndex];\n const point = calcPathPointPosition(\n fabricObject,\n connectToCommandIndex,\n connectToPointIndex,\n );\n\n if (commandType === 'Q') {\n // one control point connects to 2 points\n const point2 = calcPathPointPosition(\n fabricObject,\n commandIndex,\n pointIndex + 2,\n );\n ctx.moveTo(point2.x, point2.y);\n ctx.lineTo(left, top);\n } else {\n ctx.moveTo(left, top);\n }\n ctx.lineTo(point.x, point.y);\n ctx.stroke();\n ctx.restore();\n\n super.render(ctx, left, top, styleOverride, fabricObject);\n }\n}\n\nconst createControl = (\n commandIndexPos: number,\n pointIndexPos: number,\n isControlPoint: boolean,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n },\n connectToCommandIndex?: number,\n connectToPointIndex?: number,\n) =>\n new (isControlPoint ? PathControlPointControl : PathPointControl)({\n commandIndex: commandIndexPos,\n pointIndex: pointIndexPos,\n actionName: ACTION_NAME,\n positionHandler: pathPositionHandler,\n actionHandler: pathActionHandler,\n connectToCommandIndex,\n connectToPointIndex,\n ...options,\n ...(isControlPoint ? options.controlPointStyle : options.pointStyle),\n } as Partial);\n\nexport function createPathControls(\n path: Path,\n options: Partial & {\n controlPointStyle?: PathPointControlStyle;\n pointStyle?: PathPointControlStyle;\n } = {},\n): Record {\n const controls = {} as Record;\n let previousCommandType: TSimpleParseCommandType = 'M';\n path.path.forEach((command, commandIndex) => {\n const commandType = command[0];\n\n if (commandType !== 'Z') {\n controls[`c_${commandIndex}_${commandType}`] = createControl(\n commandIndex,\n command.length - 2,\n false,\n options,\n );\n }\n switch (commandType) {\n case 'C':\n controls[`c_${commandIndex}_C_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex - 1,\n indexFromPrevCommand(previousCommandType),\n );\n controls[`c_${commandIndex}_C_CP_2`] = createControl(\n commandIndex,\n 3,\n true,\n options,\n commandIndex,\n 5,\n );\n break;\n case 'Q':\n controls[`c_${commandIndex}_Q_CP_1`] = createControl(\n commandIndex,\n 1,\n true,\n options,\n commandIndex,\n 3,\n );\n break;\n }\n previousCommandType = commandType;\n });\n return controls;\n}\n","import { getFabricWindow } from '../env';\nimport { createCanvasElement, createCanvasElementFor } from '../util/misc/dom';\nimport { WebGLFilterBackend } from './WebGLFilterBackend';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\n\nexport const isWebGLPipelineState = (\n options: TWebGLPipelineState | T2DPipelineState,\n): options is TWebGLPipelineState => {\n return (options as TWebGLPipelineState).webgl !== undefined;\n};\n\n/**\n * Pick a method to copy data from GL context to 2d canvas. In some browsers using\n * drawImage should be faster, but is also bugged for a small combination of old hardware\n * and drivers.\n * putImageData is faster than drawImage for that specific operation.\n */\nexport const isPutImageFaster = (width: number, height: number): boolean => {\n const targetCanvas = createCanvasElementFor({ width, height });\n const sourceCanvas = createCanvasElement();\n const gl = sourceCanvas.getContext('webgl')!;\n // eslint-disable-next-line no-undef\n const imageBuffer = new ArrayBuffer(width * height * 4);\n\n const testContext = {\n imageBuffer: imageBuffer,\n } as unknown as Required;\n const testPipelineState = {\n destinationWidth: width,\n destinationHeight: height,\n targetCanvas: targetCanvas,\n } as unknown as TWebGLPipelineState;\n let startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2D.call(\n testContext,\n gl,\n testPipelineState,\n );\n const drawImageTime = getFabricWindow().performance.now() - startTime;\n\n startTime = getFabricWindow().performance.now();\n WebGLFilterBackend.prototype.copyGLTo2DPutImageData.call(\n testContext,\n gl,\n testPipelineState,\n );\n const putImageDataTime = getFabricWindow().performance.now() - startTime;\n\n return drawImageTime > putImageDataTime;\n};\n","export const highPsourceCode = `precision highp float`;\n\nexport const identityFragmentShader = `\n ${highPsourceCode};\n varying vec2 vTexCoord;\n uniform sampler2D uTexture;\n void main() {\n gl_FragColor = texture2D(uTexture, vTexCoord);\n }`;\n\nexport const vertexSource = `\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 }`;\n","import { getEnv } from '../env';\nimport type {\n T2DPipelineState,\n TWebGLAttributeLocationMap,\n TWebGLPipelineState,\n TWebGLProgramCacheItem,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport {\n highPsourceCode,\n identityFragmentShader,\n vertexSource,\n} from './shaders/baseFilter';\nimport type { Abortable } from '../typedefs';\nimport { FabricError } from '../util/internals/console';\nimport { createCanvasElementFor } from '../util/misc/dom';\n\nconst regex = new RegExp(highPsourceCode, 'g');\n\nexport class BaseFilter<\n Name extends string,\n OwnProps extends Record = object,\n SerializedProps extends Record = OwnProps,\n> {\n /**\n * Filter type\n * @param {String} type\n * @default\n */\n get type(): Name {\n return (this.constructor as typeof BaseFilter).type as Name;\n }\n\n /**\n * The class type. Used to identify which class this is.\n * This is used for serialization purposes and internally it can be used\n * to identify classes. As a developer you could use `instance of Class`\n * but to avoid importing all the code and blocking tree shaking we try\n * to avoid doing that.\n */\n static type = 'BaseFilter';\n\n /**\n * Contains the uniform locations for the fragment shader.\n * uStepW and uStepH are handled by the BaseFilter, each filter class\n * needs to specify all the one that are needed\n */\n static uniformLocations: string[] = [];\n\n declare static defaults: Record;\n\n /**\n * Constructor\n * @param {Object} [options] Options object\n */\n constructor({\n type,\n ...options\n }: { type?: never } & Partial & Record = {}) {\n Object.assign(\n this,\n (this.constructor as typeof BaseFilter).defaults,\n options,\n );\n }\n\n protected getFragmentSource(): string {\n return identityFragmentShader;\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n /**\n * Compile this filter's shader program.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context to use for shader compilation.\n * @param {String} fragmentSource fragmentShader source for compilation\n * @param {String} vertexSource vertexShader source for compilation\n */\n createProgram(\n gl: WebGLRenderingContext,\n fragmentSource: string = this.getFragmentSource(),\n vertexSource: string = this.getVertexSource(),\n ) {\n const {\n WebGLProbe: { GLPrecision = 'highp' },\n } = getEnv();\n if (GLPrecision !== 'highp') {\n fragmentSource = fragmentSource.replace(\n regex,\n highPsourceCode.replace('highp', GLPrecision),\n );\n }\n const vertexShader = gl.createShader(gl.VERTEX_SHADER);\n const fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);\n const program = gl.createProgram();\n\n if (!vertexShader || !fragmentShader || !program) {\n throw new FabricError(\n 'Vertex, fragment shader or program creation error',\n );\n }\n gl.shaderSource(vertexShader, vertexSource);\n gl.compileShader(vertexShader);\n if (!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Vertex shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n vertexShader,\n )}`,\n );\n }\n\n gl.shaderSource(fragmentShader, fragmentSource);\n gl.compileShader(fragmentShader);\n if (!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {\n throw new FabricError(\n `Fragment shader compile error for ${this.type}: ${gl.getShaderInfoLog(\n fragmentShader,\n )}`,\n );\n }\n\n gl.attachShader(program, vertexShader);\n gl.attachShader(program, fragmentShader);\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {\n throw new FabricError(\n `Shader link error for \"${this.type}\" ${gl.getProgramInfoLog(program)}`,\n );\n }\n\n const uniformLocations = this.getUniformLocations(gl, program) || {};\n uniformLocations.uStepW = gl.getUniformLocation(program, 'uStepW');\n uniformLocations.uStepH = gl.getUniformLocation(program, 'uStepH');\n\n return {\n program,\n attributeLocations: this.getAttributeLocations(gl, program),\n uniformLocations,\n };\n }\n\n /**\n * Return a map of attribute names to WebGLAttributeLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take attribute locations.\n * @returns {Object} A map of attribute names to attribute locations.\n */\n getAttributeLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLAttributeLocationMap {\n return {\n aPosition: gl.getAttribLocation(program, 'aPosition'),\n };\n }\n\n /**\n * Return a map of uniform names to WebGLUniformLocation objects.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {WebGLShaderProgram} program The shader program from which to take uniform locations.\n * @returns {Object} A map of uniform names to uniform locations.\n */\n getUniformLocations(\n gl: WebGLRenderingContext,\n program: WebGLProgram,\n ): TWebGLUniformLocationMap {\n const locations = (this.constructor as unknown as typeof BaseFilter)\n .uniformLocations;\n\n const uniformLocations: Record = {};\n for (let i = 0; i < locations.length; i++) {\n uniformLocations[locations[i]] = gl.getUniformLocation(\n program,\n locations[i],\n );\n }\n return uniformLocations;\n }\n\n /**\n * Send attribute data from this filter to its shader program on the GPU.\n *\n * @param {WebGLRenderingContext} gl The canvas context used to compile the shader program.\n * @param {Object} attributeLocations A map of shader attribute names to their locations.\n */\n sendAttributeData(\n gl: WebGLRenderingContext,\n attributeLocations: Record,\n aPositionData: Float32Array,\n ) {\n const attributeLocation = attributeLocations.aPosition;\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attributeLocation);\n gl.vertexAttribPointer(attributeLocation, 2, gl.FLOAT, false, 0, 0);\n gl.bufferData(gl.ARRAY_BUFFER, aPositionData, gl.STATIC_DRAW);\n }\n\n _setupFrameBuffer(options: TWebGLPipelineState) {\n const gl = options.context;\n if (options.passes > 1) {\n const width = options.destinationWidth;\n const height = options.destinationHeight;\n if (options.sourceWidth !== width || options.sourceHeight !== height) {\n gl.deleteTexture(options.targetTexture);\n options.targetTexture = options.filterBackend.createTexture(\n gl,\n width,\n height,\n );\n }\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n options.targetTexture,\n 0,\n );\n } else {\n // draw last filter on canvas and not to framebuffer.\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\n gl.finish();\n }\n }\n\n _swapTextures(options: TWebGLPipelineState) {\n options.passes--;\n options.pass++;\n const temp = options.targetTexture;\n options.targetTexture = options.sourceTexture;\n options.sourceTexture = temp;\n }\n\n /**\n * Generic isNeutral implementation for one parameter based filters.\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * Other filters may need their own version ( ColorMatrix, HueRotation, gamma, ComposedFilter )\n * @param {Object} options\n **/\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isNeutralState(options?: any): boolean {\n return false;\n }\n\n /**\n * Apply this filter to the input image data provided.\n *\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n this._setupFrameBuffer(options);\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(_options: T2DPipelineState): void {\n // override by subclass\n }\n\n /**\n * Returns a string that represent the current selected shader code for the filter.\n * Used to force recompilation when parameters change or to retrieve the shader from cache\n * @type string\n **/\n getCacheKey(): string {\n return this.type;\n }\n\n /**\n * Retrieves the cached shader.\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n * @return {WebGLProgram} the compiled program shader\n */\n retrieveShader(options: TWebGLPipelineState): TWebGLProgramCacheItem {\n const key = this.getCacheKey();\n if (!options.programCache[key]) {\n options.programCache[key] = this.createProgram(options.context);\n }\n return options.programCache[key];\n }\n\n /**\n * Apply this filter using webgl.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.originalTexture The texture of the original input image.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context;\n const shader = this.retrieveShader(options);\n if (options.pass === 0 && options.originalTexture) {\n gl.bindTexture(gl.TEXTURE_2D, options.originalTexture);\n } else {\n gl.bindTexture(gl.TEXTURE_2D, options.sourceTexture);\n }\n gl.useProgram(shader.program);\n this.sendAttributeData(gl, shader.attributeLocations, options.aPosition);\n\n gl.uniform1f(shader.uniformLocations.uStepW, 1 / options.sourceWidth);\n gl.uniform1f(shader.uniformLocations.uStepH, 1 / options.sourceHeight);\n\n this.sendUniformData(gl, shader.uniformLocations);\n gl.viewport(0, 0, options.destinationWidth, options.destinationHeight);\n gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);\n }\n\n bindAdditionalTexture(\n gl: WebGLRenderingContext,\n texture: WebGLTexture,\n textureUnit: number,\n ) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, texture);\n // reset active texture to 0 as usual\n gl.activeTexture(gl.TEXTURE0);\n }\n\n unbindAdditionalTexture(gl: WebGLRenderingContext, textureUnit: number) {\n gl.activeTexture(textureUnit);\n gl.bindTexture(gl.TEXTURE_2D, null);\n gl.activeTexture(gl.TEXTURE0);\n }\n\n /**\n * Send uniform data from this filter to its shader program on the GPU.\n *\n * Intended to be overridden by subclasses.\n *\n * @param {WebGLRenderingContext} _gl The canvas context used to compile the shader program.\n * @param {Object} _uniformLocations A map of shader uniform names to their locations.\n */\n sendUniformData(\n _gl: WebGLRenderingContext,\n _uniformLocations: TWebGLUniformLocationMap,\n ): void {\n // override by subclass\n }\n\n /**\n * If needed by a 2d filter, this functions can create an helper canvas to be used\n * remember that options.targetCanvas is available for use till end of chain.\n */\n createHelpLayer(options: T2DPipelineState) {\n if (!options.helpLayer) {\n const { sourceWidth, sourceHeight } = options;\n const helpLayer = createCanvasElementFor({\n width: sourceWidth,\n height: sourceHeight,\n });\n options.helpLayer = helpLayer;\n }\n }\n\n /**\n * Returns object representation of an instance\n * It will automatically export the default values of a filter,\n * stored in the static defaults property.\n * @return {Object} Object representation of an instance\n */\n toObject(): { type: Name } & SerializedProps {\n const defaultKeys = Object.keys(\n (this.constructor as typeof BaseFilter).defaults || {},\n ) as (keyof SerializedProps)[];\n\n return {\n type: this.type,\n ...defaultKeys.reduce((acc, key) => {\n acc[key] = this[\n key as keyof this\n ] as unknown as (typeof acc)[typeof key];\n return acc;\n }, {} as SerializedProps),\n };\n }\n\n /**\n * Returns a JSON representation of an instance\n * @return {Object} JSON\n */\n toJSON() {\n // delegate, not alias\n return this.toObject();\n }\n\n static async fromObject(\n { type, ...filterOptions }: Record,\n _options: Abortable,\n ): Promise> {\n return new this(filterOptions);\n }\n}\n","export const blendColorFragmentSource = {\n multiply: 'gl_FragColor.rgb *= uColor.rgb;\\n',\n screen:\n 'gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);\\n',\n add: 'gl_FragColor.rgb += uColor.rgb;\\n',\n difference: 'gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);\\n',\n subtract: 'gl_FragColor.rgb -= uColor.rgb;\\n',\n lighten: 'gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);\\n',\n darken: 'gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);\\n',\n exclusion:\n 'gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);\\n',\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 `,\n tint: `\n gl_FragColor.rgb *= (1.0 - uColor.a);\n gl_FragColor.rgb += uColor.rgb;\n `,\n} as const;\n","import { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { blendColorFragmentSource } from './shaders/blendColor';\n\nexport type TBlendMode =\n | 'multiply'\n | 'add'\n | 'difference'\n | 'screen'\n | 'subtract'\n | 'darken'\n | 'lighten'\n | 'overlay'\n | 'exclusion'\n | 'tint';\n\ntype BlendColorOwnProps = {\n color: string;\n mode: TBlendMode;\n alpha: number;\n};\n\nexport const blendColorDefaultValues: BlendColorOwnProps = {\n color: '#F95C63',\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Color Blend filter class\n * @example\n * const filter = new BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendColor extends BaseFilter<'BlendColor', BlendColorOwnProps> {\n /**\n * Color to make the blend operation with. default to a reddish color since black or white\n * gives always strong result.\n * @type String\n * @default\n **/\n declare color: BlendColorOwnProps['color'];\n\n /**\n * Blend mode for the filter: one of multiply, add, difference, screen, subtract,\n * darken, lighten, overlay, exclusion, tint.\n * @type String\n * @default\n **/\n declare mode: BlendColorOwnProps['mode'];\n /**\n * alpha value. represent the strength of the blend color operation.\n * @type Number\n * @default\n **/\n declare alpha: BlendColorOwnProps['alpha'];\n\n static defaults = blendColorDefaultValues;\n\n static type = 'BlendColor';\n\n static uniformLocations = ['uColor'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n protected getFragmentSource(): string {\n 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 ${blendColorFragmentSource[this.mode]}\n }\n }\n `;\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const source = new Color(this.color).getSource();\n const alpha = this.alpha;\n const tr = source[0] * alpha;\n const tg = source[1] * alpha;\n const tb = source[2] * alpha;\n const alpha1 = 1 - alpha;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n let oR, oG, oB;\n switch (this.mode) {\n case 'multiply':\n oR = (r * tr) / 255;\n oG = (g * tg) / 255;\n oB = (b * tb) / 255;\n break;\n case 'screen':\n oR = 255 - ((255 - r) * (255 - tr)) / 255;\n oG = 255 - ((255 - g) * (255 - tg)) / 255;\n oB = 255 - ((255 - b) * (255 - tb)) / 255;\n break;\n case 'add':\n oR = r + tr;\n oG = g + tg;\n oB = b + tb;\n break;\n case 'difference':\n oR = Math.abs(r - tr);\n oG = Math.abs(g - tg);\n oB = Math.abs(b - tb);\n break;\n case 'subtract':\n oR = r - tr;\n oG = g - tg;\n oB = b - tb;\n break;\n case 'darken':\n oR = Math.min(r, tr);\n oG = Math.min(g, tg);\n oB = Math.min(b, tb);\n break;\n case 'lighten':\n oR = Math.max(r, tr);\n oG = Math.max(g, tg);\n oB = Math.max(b, tb);\n break;\n case 'overlay':\n oR =\n tr < 128\n ? (2 * r * tr) / 255\n : 255 - (2 * (255 - r) * (255 - tr)) / 255;\n oG =\n tg < 128\n ? (2 * g * tg) / 255\n : 255 - (2 * (255 - g) * (255 - tg)) / 255;\n oB =\n tb < 128\n ? (2 * b * tb) / 255\n : 255 - (2 * (255 - b) * (255 - tb)) / 255;\n break;\n case 'exclusion':\n oR = tr + r - (2 * tr * r) / 255;\n oG = tg + g - (2 * tg * g) / 255;\n oB = tb + b - (2 * tb * b) / 255;\n break;\n case 'tint':\n oR = tr + r * alpha1;\n oG = tg + g * alpha1;\n oB = tb + b * alpha1;\n }\n data[i] = oR;\n data[i + 1] = oG;\n data[i + 2] = oB;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource();\n source[0] = (this.alpha * source[0]) / 255;\n source[1] = (this.alpha * source[1]) / 255;\n source[2] = (this.alpha * source[2]) / 255;\n source[3] = this.alpha;\n gl.uniform4fv(uniformLocations.uColor, source);\n }\n}\n\nclassRegistry.setClass(BlendColor);\n","import type { TBlendImageMode } from '../BlendImage';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\n} as const;\n\nexport const vertexSource = `\n attribute vec2 aPosition;\n varying vec2 vTexCoord;\n varying vec2 vTexCoord2;\n uniform mat3 uTransformMatrix;\n void main() {\n vTexCoord = aPosition;\n vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\n gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n }\n ` as const;\n","import { FabricImage } from '../shapes/Image';\nimport { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport type { WebGLFilterBackend } from './WebGLFilterBackend';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource, vertexSource } from './shaders/blendImage';\n\nexport type TBlendImageMode = 'multiply' | 'mask';\n\ntype BlendImageOwnProps = {\n mode: TBlendImageMode;\n alpha: number;\n};\n\nexport const blendImageDefaultValues: BlendImageOwnProps = {\n mode: 'multiply',\n alpha: 1,\n};\n\n/**\n * Image Blend filter class\n * @example\n * const filter = new filters.BlendColor({\n * color: '#000',\n * mode: 'multiply'\n * });\n *\n * const filter = new BlendImage({\n * image: fabricImageObject,\n * mode: 'multiply'\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class BlendImage extends BaseFilter<'BlendImage', BlendImageOwnProps> {\n /**\n * Image to make the blend operation with.\n **/\n declare image: FabricImage;\n\n /**\n * Blend mode for the filter: either 'multiply' or 'mask'. 'multiply' will\n * multiply the values of each channel (R, G, B, and A) of the filter image by\n * their corresponding values in the base image. 'mask' will only look at the\n * alpha channel of the filter image, and apply those values to the base\n * image's alpha channel.\n * @type String\n * @default\n **/\n declare mode: BlendImageOwnProps['mode'];\n\n /**\n * alpha value. represent the strength of the blend image operation.\n * not implemented.\n **/\n declare alpha: BlendImageOwnProps['alpha'];\n\n static type = 'BlendImage';\n\n static defaults = blendImageDefaultValues;\n\n static uniformLocations = ['uTransformMatrix', 'uImage'];\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource(): string {\n return fragmentSource[this.mode];\n }\n\n getVertexSource(): string {\n return vertexSource;\n }\n\n applyToWebGL(options: TWebGLPipelineState) {\n const gl = options.context,\n texture = this.createTexture(options.filterBackend, this.image);\n this.bindAdditionalTexture(gl, texture!, gl.TEXTURE1);\n super.applyToWebGL(options);\n this.unbindAdditionalTexture(gl, gl.TEXTURE1);\n }\n\n createTexture(backend: WebGLFilterBackend, image: FabricImage) {\n return backend.getCachedTexture(image.cacheKey, image.getElement());\n }\n\n /**\n * Calculate a transformMatrix to adapt the image to blend over\n * @param {Object} options\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n calculateMatrix() {\n const image = this.image,\n { width, height } = image.getElement();\n return [\n 1 / image.scaleX,\n 0,\n 0,\n 0,\n 1 / image.scaleY,\n 0,\n -image.left / width,\n -image.top / height,\n 1,\n ];\n }\n\n /**\n * Apply the Blend operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({\n imageData: { data, width, height },\n filterBackend: { resources },\n }: T2DPipelineState) {\n const image = this.image;\n if (!resources.blendImage) {\n resources.blendImage = createCanvasElement();\n }\n const canvas1 = resources.blendImage;\n const context = canvas1.getContext('2d')!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas1.width = width;\n canvas1.height = height;\n } else {\n context.clearRect(0, 0, width, height);\n }\n context.setTransform(\n image.scaleX,\n 0,\n 0,\n image.scaleY,\n image.left,\n image.top,\n );\n context.drawImage(image.getElement(), 0, 0, width, height);\n const blendData = context.getImageData(0, 0, width, height).data;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const a = data[i + 3];\n\n const tr = blendData[i];\n const tg = blendData[i + 1];\n const tb = blendData[i + 2];\n const ta = blendData[i + 3];\n\n switch (this.mode) {\n case 'multiply':\n data[i] = (r * tr) / 255;\n data[i + 1] = (g * tg) / 255;\n data[i + 2] = (b * tb) / 255;\n data[i + 3] = (a * ta) / 255;\n break;\n case 'mask':\n data[i + 3] = ta;\n break;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const matrix = this.calculateMatrix();\n gl.uniform1i(uniformLocations.uImage, 1); // texture unit 1.\n gl.uniformMatrix3fv(uniformLocations.uTransformMatrix, false, matrix);\n }\n\n /**\n * Returns object representation of an instance\n * TODO: Handle the possibility of missing image better.\n * As of now a BlendImage filter without image can't be used with fromObject\n * @return {Object} Object representation of an instance\n */\n toObject(): {\n type: 'BlendImage';\n image: ReturnType;\n } & BlendImageOwnProps {\n return {\n ...super.toObject(),\n image: this.image && this.image.toObject(),\n };\n }\n\n /**\n * Create filter instance from an object representation\n * @static\n * @param {object} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting image loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static async fromObject(\n { type, image, ...filterOptions }: Record,\n options: { signal: AbortSignal },\n ): Promise> {\n return FabricImage.fromObject(image, options).then(\n (enlivedImage) =>\n new this({ ...filterOptions, image: enlivedImage }) as BlendImage,\n );\n }\n}\n\nclassRegistry.setClass(BlendImage);\n","export const fragmentSource = `\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 total = 0.0;\n float offset = random(v3offset);\n for (float t = -nSamples; t <= nSamples; t++) {\n float percent = (t + offset - 0.5) / nSamples;\n float weight = 1.0 - abs(percent);\n color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;\n total += weight;\n }\n gl_FragColor = color / total;\n }\n ` as const;\n","import { createCanvasElement } from '../util/misc/dom';\nimport { BaseFilter } from './BaseFilter';\nimport type {\n TWebGLPipelineState,\n T2DPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/blur';\n\ntype BlurOwnProps = {\n blur: number;\n};\n\nexport const blurDefaultValues: BlurOwnProps = {\n blur: 0,\n};\n\n/**\n * Blur filter class\n * @example\n * const filter = new Blur({\n * blur: 0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Blur extends BaseFilter<'Blur', BlurOwnProps> {\n /**\n * blur value, in percentage of image dimensions.\n * specific to keep the image blur constant at different resolutions\n * range between 0 and 1.\n * @type Number\n * @default\n */\n declare blur: BlurOwnProps['blur'];\n\n declare horizontal: boolean;\n declare aspectRatio: number;\n\n static type = 'Blur';\n\n static defaults = blurDefaultValues;\n\n static uniformLocations = ['uDelta'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n // this aspectRatio is used to give the same blur to vertical and horizontal\n this.aspectRatio = options.sourceWidth / options.sourceHeight;\n options.passes++;\n this._setupFrameBuffer(options);\n this.horizontal = true;\n this.applyToWebGL(options);\n this._swapTextures(options);\n this._setupFrameBuffer(options);\n this.horizontal = false;\n this.applyToWebGL(options);\n this._swapTextures(options);\n } else {\n this.applyTo2d(options);\n }\n }\n\n applyTo2d(options: T2DPipelineState) {\n options.imageData = this.simpleBlur(options);\n }\n\n simpleBlur({\n ctx,\n imageData,\n filterBackend: { resources },\n }: T2DPipelineState) {\n const { width, height } = imageData;\n if (!resources.blurLayer1) {\n resources.blurLayer1 = createCanvasElement();\n resources.blurLayer2 = createCanvasElement();\n }\n const canvas1 = resources.blurLayer1!;\n const canvas2 = resources.blurLayer2!;\n if (canvas1.width !== width || canvas1.height !== height) {\n canvas2.width = canvas1.width = width;\n canvas2.height = canvas1.height = height;\n }\n const ctx1 = canvas1.getContext('2d')!,\n ctx2 = canvas2.getContext('2d')!,\n nSamples = 15,\n blur = this.blur * 0.06 * 0.5;\n let random, percent, j, i;\n\n // load first canvas\n ctx1.putImageData(imageData, 0, 0);\n ctx2.clearRect(0, 0, width, height);\n\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * width + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, j, random);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n for (i = -nSamples; i <= nSamples; i++) {\n random = (Math.random() - 0.5) / 4;\n percent = i / nSamples;\n j = blur * percent * height + random;\n ctx2.globalAlpha = 1 - Math.abs(percent);\n ctx2.drawImage(canvas1, random, j);\n ctx1.drawImage(canvas2, 0, 0);\n ctx2.globalAlpha = 1;\n ctx2.clearRect(0, 0, canvas2.width, canvas2.height);\n }\n ctx.drawImage(canvas1, 0, 0);\n const newImageData = ctx.getImageData(0, 0, canvas1.width, canvas1.height);\n ctx1.globalAlpha = 1;\n ctx1.clearRect(0, 0, canvas1.width, canvas1.height);\n return newImageData;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const delta = this.chooseRightDelta();\n gl.uniform2fv(uniformLocations.uDelta, delta);\n }\n\n isNeutralState() {\n return this.blur === 0;\n }\n\n /**\n * choose right value of image percentage to blur with\n * @returns {Array} a numeric array with delta values\n */\n chooseRightDelta() {\n let blurScale = 1;\n const delta = [0, 0];\n if (this.horizontal) {\n if (this.aspectRatio > 1) {\n // image is wide, i want to shrink radius horizontal\n blurScale = 1 / this.aspectRatio;\n }\n } else {\n if (this.aspectRatio < 1) {\n // image is tall, i want to shrink radius vertical\n blurScale = this.aspectRatio;\n }\n }\n const blur = blurScale * this.blur * 0.12;\n if (this.horizontal) {\n delta[0] = blur;\n } else {\n delta[1] = blur;\n }\n return delta;\n }\n}\n\nclassRegistry.setClass(Blur);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/brightness';\n\ntype BrightnessOwnProps = {\n brightness: number;\n};\n\nexport const brightnessDefaultValues: BrightnessOwnProps = {\n brightness: 0,\n};\n\n/**\n * Brightness filter class\n * @example\n * const filter = new Brightness({\n * brightness: 0.05\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Brightness extends BaseFilter<'Brightness', BrightnessOwnProps> {\n /**\n * Brightness value, from -1 to 1.\n * translated to -255 to 255 for 2d\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Number} brightness\n * @default\n */\n declare brightness: BrightnessOwnProps['brightness'];\n\n static type = 'Brightness';\n\n static defaults = brightnessDefaultValues;\n\n static uniformLocations = ['uBrightness'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const brightness = Math.round(this.brightness * 255);\n for (let i = 0; i < data.length; i += 4) {\n data[i] += brightness;\n data[i + 1] += brightness;\n data[i + 2] += brightness;\n }\n }\n\n isNeutralState() {\n return this.brightness === 0;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBrightness, this.brightness);\n }\n}\n\nclassRegistry.setClass(Brightness);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TMatColorMatrix,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/colorMatrix';\n\nexport type ColorMatrixOwnProps = {\n matrix: TMatColorMatrix;\n colorsOnly: boolean;\n};\n\nexport const colorMatrixDefaultValues: ColorMatrixOwnProps = {\n matrix: [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0],\n colorsOnly: true,\n};\n\n/**\n * Color Matrix filter class\n * @see {@link http://fabricjs.com/image-filters|ImageFilters demo}\n * @see {@Link http://phoboslab.org/log/2013/11/fast-image-filters-with-webgl demo}\n * @example Kodachrome filter\n * const filter = new ColorMatrix({\n * matrix: [\n 1.1285582396593525, -0.3967382283601348, -0.03992559172921793, 0, 63.72958762196502,\n -0.16404339962244616, 1.0835251566291304, -0.05498805115633132, 0, 24.732407896706203,\n -0.16786010706155763, -0.5603416277695248, 1.6014850761964943, 0, 35.62982807460946,\n 0, 0, 0, 1, 0\n ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class ColorMatrix<\n Name extends string = 'ColorMatrix',\n OwnProps extends object = ColorMatrixOwnProps,\n SerializedProps extends object = ColorMatrixOwnProps,\n> extends BaseFilter {\n /**\n * Colormatrix for pixels.\n * array of 20 floats. Numbers in positions 4, 9, 14, 19 loose meaning\n * outside the -1, 1 range.\n * 0.0039215686 is the part of 1 that get translated to 1 in 2d\n * @param {Array} matrix array of 20 numbers.\n * @default\n */\n declare matrix: ColorMatrixOwnProps['matrix'];\n\n /**\n * Lock the colormatrix on the color part, skipping alpha, mainly for non webgl scenario\n * to save some calculation\n * @type Boolean\n * @default true\n */\n declare colorsOnly: ColorMatrixOwnProps['colorsOnly'];\n\n static type = 'ColorMatrix';\n\n static defaults = colorMatrixDefaultValues;\n\n static uniformLocations = ['uColorMatrix', 'uConstants'];\n\n getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Apply the ColorMatrix operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n m = this.matrix,\n colorsOnly = this.colorsOnly;\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n data[i] = r * m[0] + g * m[1] + b * m[2] + m[4] * 255;\n data[i + 1] = r * m[5] + g * m[6] + b * m[7] + m[9] * 255;\n data[i + 2] = r * m[10] + g * m[11] + b * m[12] + m[14] * 255;\n if (!colorsOnly) {\n const a = data[i + 3];\n data[i] += a * m[3];\n data[i + 1] += a * m[8];\n data[i + 2] += a * m[13];\n data[i + 3] += a * m[18];\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const m = this.matrix,\n matrix = [\n m[0],\n m[1],\n m[2],\n m[3],\n m[5],\n m[6],\n m[7],\n m[8],\n m[10],\n m[11],\n m[12],\n m[13],\n m[15],\n m[16],\n m[17],\n m[18],\n ],\n constants = [m[4], m[9], m[14], m[19]];\n gl.uniformMatrix4fv(uniformLocations.uColorMatrix, false, matrix);\n gl.uniform4fv(uniformLocations.uConstants, constants);\n }\n\n toObject(): { type: Name } & SerializedProps {\n return {\n ...super.toObject(),\n matrix: [...this.matrix] as TMatColorMatrix,\n };\n }\n}\n\nclassRegistry.setClass(ColorMatrix);\n","import { ColorMatrix } from './ColorMatrix';\nimport { classRegistry } from '../ClassRegistry';\nimport type { TMatColorMatrix } from './typedefs';\n\ntype FixedFiltersOwnProps = {\n colorsOnly: boolean;\n};\n\nexport function createColorMatrixFilter(key: string, matrix: TMatColorMatrix) {\n const newClass = class extends ColorMatrix<\n typeof key,\n FixedFiltersOwnProps,\n FixedFiltersOwnProps\n > {\n static type = key;\n\n static defaults = {\n colorsOnly: false,\n matrix,\n };\n\n toObject(): { type: string } & FixedFiltersOwnProps {\n return { type: this.type, colorsOnly: this.colorsOnly };\n }\n };\n classRegistry.setClass(newClass, key);\n return newClass as typeof ColorMatrix;\n}\n\nexport const Brownie = createColorMatrixFilter(\n 'Brownie',\n [\n 0.5997, 0.34553, -0.27082, 0, 0.186, -0.0377, 0.86095, 0.15059, 0, -0.1449,\n 0.24113, -0.07441, 0.44972, 0, -0.02965, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Vintage = createColorMatrixFilter(\n 'Vintage',\n [\n 0.62793, 0.32021, -0.03965, 0, 0.03784, 0.02578, 0.64411, 0.03259, 0,\n 0.02926, 0.0466, -0.08512, 0.52416, 0, 0.02023, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Kodachrome = createColorMatrixFilter(\n 'Kodachrome',\n [\n 1.12855, -0.39673, -0.03992, 0, 0.24991, -0.16404, 1.08352, -0.05498, 0,\n 0.09698, -0.16786, -0.56034, 1.60148, 0, 0.13972, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Technicolor = createColorMatrixFilter(\n 'Technicolor',\n [\n 1.91252, -0.85453, -0.09155, 0, 0.04624, -0.30878, 1.76589, -0.10601, 0,\n -0.27589, -0.2311, -0.75018, 1.84759, 0, 0.12137, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Polaroid = createColorMatrixFilter(\n 'Polaroid',\n [\n 1.438, -0.062, -0.062, 0, 0, -0.122, 1.378, -0.122, 0, 0, -0.016, -0.016,\n 1.483, 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const Sepia = createColorMatrixFilter(\n 'Sepia',\n [\n 0.393, 0.769, 0.189, 0, 0, 0.349, 0.686, 0.168, 0, 0, 0.272, 0.534, 0.131,\n 0, 0, 0, 0, 0, 1, 0,\n ],\n);\n\nexport const BlackWhite = createColorMatrixFilter(\n 'BlackWhite',\n [\n 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,\n 1, 0,\n ],\n);\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLPipelineState } from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\n\ntype ComposedOwnProps = {\n subFilters: BaseFilter[];\n};\n\ntype ComposedSerializedProps = {\n subFilters: Record[];\n};\n\n/**\n * A container class that knows how to apply a sequence of filters to an input image.\n */\nexport class Composed extends BaseFilter<\n 'Composed',\n ComposedOwnProps,\n ComposedSerializedProps\n> {\n /**\n * A non sparse array of filters to apply\n */\n declare subFilters: ComposedOwnProps['subFilters'];\n\n static type = 'Composed';\n\n constructor(\n options: { subFilters?: BaseFilter[] } & Record<\n string,\n any\n > = {},\n ) {\n super(options);\n this.subFilters = options.subFilters || [];\n }\n\n /**\n * Apply this container's filters to the input image provided.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be applied.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n options.passes += this.subFilters.length - 1;\n }\n this.subFilters.forEach((filter) => {\n filter.applyTo(options);\n });\n }\n\n /**\n * Serialize this filter into JSON.\n * @returns {Object} A JSON representation of this filter.\n */\n toObject() {\n return {\n type: this.type,\n subFilters: this.subFilters.map((filter) => filter.toObject()),\n };\n }\n\n isNeutralState() {\n return !this.subFilters.some((filter) => !filter.isNeutralState());\n }\n\n /**\n * Deserialize a JSON definition of a ComposedFilter into a concrete instance.\n * @static\n * @param {oject} object Object to create an instance from\n * @param {object} [options]\n * @param {AbortSignal} [options.signal] handle aborting `BlendImage` filter loading, see https://developer.mozilla.org/en-US/docs/Web/API/AbortController/signal\n * @returns {Promise}\n */\n static fromObject(\n object: Record,\n options: { signal: AbortSignal },\n ): Promise {\n return Promise.all(\n ((object.subFilters || []) as BaseFilter[]).map(\n (filter) =>\n classRegistry\n .getClass(filter.type)\n .fromObject(filter, options),\n ),\n ).then(\n (enlivedFilters) => new this({ subFilters: enlivedFilters }) as Composed,\n );\n }\n}\n\nclassRegistry.setClass(Composed);\n","export const fragmentSource = `\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 }`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/constrast';\n\ntype ContrastOwnProps = {\n contrast: number;\n};\n\nexport const contrastDefaultValues: ContrastOwnProps = {\n contrast: 0,\n};\n\n/**\n * Contrast filter class\n * @example\n * const filter = new Contrast({\n * contrast: 0.25\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Contrast extends BaseFilter<'Contrast', ContrastOwnProps> {\n /**\n * contrast value, range from -1 to 1.\n * @param {Number} contrast\n * @default 0\n */\n declare contrast: ContrastOwnProps['contrast'];\n\n static type = 'Contrast';\n\n static defaults = contrastDefaultValues;\n\n static uniformLocations = ['uContrast'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n isNeutralState() {\n return this.contrast === 0;\n }\n\n /**\n * Apply the Contrast operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const contrast = Math.floor(this.contrast * 255),\n contrastF = (259 * (contrast + 255)) / (255 * (259 - contrast));\n\n for (let i = 0; i < data.length; i += 4) {\n data[i] = contrastF * (data[i] - 128) + 128;\n data[i + 1] = contrastF * (data[i + 1] - 128) + 128;\n data[i + 2] = contrastF * (data[i + 2] - 128) + 128;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uContrast, this.contrast);\n }\n}\n\nclassRegistry.setClass(Contrast);\n","export const fragmentSource = {\n 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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/convolute';\n\nexport type ConvoluteOwnProps = {\n opaque: boolean;\n matrix: number[];\n};\n\nexport const convoluteDefaultValues: ConvoluteOwnProps = {\n opaque: false,\n matrix: [0, 0, 0, 0, 1, 0, 0, 0, 0],\n};\n\n/**\n * Adapted from html5rocks article\n * @example Sharpen filter\n * const filter = new Convolute({\n * matrix: [ 0, -1, 0,\n * -1, 5, -1,\n * 0, -1, 0 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Blur filter\n * const filter = new Convolute({\n * matrix: [ 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9,\n * 1/9, 1/9, 1/9 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter\n * const filter = new Convolute({\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n * @example Emboss filter with opaqueness\n * const filter = new Convolute({\n * opaque: true,\n * matrix: [ 1, 1, 1,\n * 1, 0.7, -1,\n * -1, -1, -1 ]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Convolute extends BaseFilter<'Convolute', ConvoluteOwnProps> {\n /*\n * Opaque value (true/false)\n */\n declare opaque: ConvoluteOwnProps['opaque'];\n\n /*\n * matrix for the filter, max 9x9\n */\n declare matrix: ConvoluteOwnProps['matrix'];\n\n static type = 'Convolute';\n\n static defaults = convoluteDefaultValues;\n\n static uniformLocations = ['uMatrix', 'uOpaque', 'uHalfSize', 'uSize'];\n\n getCacheKey() {\n return `${this.type}_${Math.sqrt(this.matrix.length)}_${\n this.opaque ? 1 : 0\n }` as keyof typeof fragmentSource;\n }\n\n getFragmentSource() {\n return fragmentSource[this.getCacheKey()];\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d(options: T2DPipelineState) {\n const imageData = options.imageData,\n data = imageData.data,\n weights = this.matrix,\n side = Math.round(Math.sqrt(weights.length)),\n halfSide = Math.floor(side / 2),\n sw = imageData.width,\n sh = imageData.height,\n output = options.ctx.createImageData(sw, sh),\n dst = output.data,\n // go through the destination image pixels\n alphaFac = this.opaque ? 1 : 0;\n let r, g, b, a, dstOff, scx, scy, srcOff, wt, x, y, cx, cy;\n\n for (y = 0; y < sh; y++) {\n for (x = 0; x < sw; x++) {\n dstOff = (y * sw + x) * 4;\n // calculate the weighed sum of the source image pixels that\n // fall under the convolution matrix\n r = 0;\n g = 0;\n b = 0;\n a = 0;\n\n for (cy = 0; cy < side; cy++) {\n for (cx = 0; cx < side; cx++) {\n scy = y + cy - halfSide;\n scx = x + cx - halfSide;\n\n // eslint-disable-next-line max-depth\n if (scy < 0 || scy >= sh || scx < 0 || scx >= sw) {\n continue;\n }\n\n srcOff = (scy * sw + scx) * 4;\n wt = weights[cy * side + cx];\n\n r += data[srcOff] * wt;\n g += data[srcOff + 1] * wt;\n b += data[srcOff + 2] * wt;\n // eslint-disable-next-line max-depth\n if (!alphaFac) {\n a += data[srcOff + 3] * wt;\n }\n }\n }\n dst[dstOff] = r;\n dst[dstOff + 1] = g;\n dst[dstOff + 2] = b;\n if (!alphaFac) {\n dst[dstOff + 3] = a;\n } else {\n dst[dstOff + 3] = data[dstOff + 3];\n }\n }\n }\n options.imageData = output;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1fv(uniformLocations.uMatrix, this.matrix);\n }\n\n /**\n * Returns object representation of an instance\n * @return {Object} Object representation of an instance\n */\n toObject() {\n return {\n ...super.toObject(),\n opaque: this.opaque,\n matrix: [...this.matrix],\n };\n }\n}\n\nclassRegistry.setClass(Convolute);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/gamma';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nconst GAMMA = 'Gamma' as const;\n\nexport type GammaInput = [number, number, number];\n\nexport type GammaOwnProps = {\n gamma: GammaInput;\n};\n\nexport const gammaDefaultValues: GammaOwnProps = {\n gamma: [1, 1, 1],\n};\n\n/**\n * Gamma filter class\n * @example\n * const filter = new Gamma({\n * gamma: [1, 0.5, 2.1]\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Gamma extends BaseFilter {\n /**\n * Gamma array value, from 0.01 to 2.2.\n * @param {Array} gamma\n * @default\n */\n declare gamma: GammaOwnProps['gamma'];\n declare rgbValues?: {\n r: Uint8Array;\n g: Uint8Array;\n b: Uint8Array;\n };\n\n static type = GAMMA;\n\n static defaults = gammaDefaultValues;\n\n static uniformLocations = ['uGamma'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n constructor(options: { gamma?: GammaInput } = {}) {\n super(options);\n this.gamma =\n options.gamma ||\n ((\n this.constructor as typeof Gamma\n ).defaults.gamma.concat() as GammaInput);\n }\n\n /**\n * Apply the Gamma operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const gamma = this.gamma,\n rInv = 1 / gamma[0],\n gInv = 1 / gamma[1],\n bInv = 1 / gamma[2];\n\n if (!this.rgbValues) {\n this.rgbValues = {\n r: new Uint8Array(256),\n g: new Uint8Array(256),\n b: new Uint8Array(256),\n };\n }\n\n // This is an optimization - pre-compute a look-up table for each color channel\n // instead of performing these pow calls for each pixel in the image.\n const rgb = this.rgbValues;\n for (let i = 0; i < 256; i++) {\n rgb.r[i] = Math.pow(i / 255, rInv) * 255;\n rgb.g[i] = Math.pow(i / 255, gInv) * 255;\n rgb.b[i] = Math.pow(i / 255, bInv) * 255;\n }\n for (let i = 0; i < data.length; i += 4) {\n data[i] = rgb.r[data[i]];\n data[i + 1] = rgb.g[data[i + 1]];\n data[i + 2] = rgb.b[data[i + 2]];\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform3fv(uniformLocations.uGamma, this.gamma);\n }\n\n isNeutralState() {\n const { gamma } = this;\n return gamma[0] === 1 && gamma[1] === 1 && gamma[2] === 1;\n }\n\n toObject(): { type: typeof GAMMA; gamma: GammaInput } {\n return {\n type: GAMMA,\n gamma: this.gamma.concat() as GammaInput,\n };\n }\n}\n\nclassRegistry.setClass(Gamma);\n","import type { TGrayscaleMode } from '../Grayscale';\n\nexport const fragmentSource: Record = {\n 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 `,\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 `,\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 `,\n};\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/grayscale';\n\nexport type TGrayscaleMode = 'average' | 'lightness' | 'luminosity';\n\ntype GrayscaleOwnProps = {\n mode: TGrayscaleMode;\n};\n\nexport const grayscaleDefaultValues: GrayscaleOwnProps = {\n mode: 'average',\n};\n\n/**\n * Grayscale image filter class\n * @example\n * const filter = new Grayscale();\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Grayscale extends BaseFilter<'Grayscale', GrayscaleOwnProps> {\n declare mode: TGrayscaleMode;\n\n static type = 'Grayscale';\n\n static defaults = grayscaleDefaultValues;\n\n static uniformLocations = ['uMode'];\n\n /**\n * Apply the Grayscale operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0, value: number; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n switch (this.mode) {\n case 'average':\n value = (r + g + b) / 3;\n break;\n case 'lightness':\n value = (Math.min(r, g, b) + Math.max(r, g, b)) / 2;\n break;\n case 'luminosity':\n value = 0.21 * r + 0.72 * g + 0.07 * b;\n break;\n }\n\n data[i + 2] = data[i + 1] = data[i] = value;\n }\n }\n\n getCacheKey() {\n return `${this.type}_${this.mode}`;\n }\n\n getFragmentSource() {\n return fragmentSource[this.mode];\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const mode = 1;\n gl.uniform1i(uniformLocations.uMode, mode);\n }\n\n /**\n * Grayscale filter isNeutralState implementation\n * The filter is never neutral\n * on the image\n **/\n isNeutralState() {\n return false;\n }\n}\n\nclassRegistry.setClass(Grayscale);\n","import { cos } from '../util/misc/cos';\nimport { sin } from '../util/misc/sin';\nimport {\n ColorMatrix,\n type ColorMatrixOwnProps,\n colorMatrixDefaultValues,\n} from './ColorMatrix';\nimport type { TWebGLPipelineState, T2DPipelineState } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\n\nexport type HueRotationOwnProps = ColorMatrixOwnProps & {\n rotation: number;\n};\n\nexport type HueRotationSerializedProps = {\n rotation: number;\n};\n\nexport const hueRotationDefaultValues: HueRotationOwnProps = {\n ...colorMatrixDefaultValues,\n rotation: 0,\n};\n\n/**\n * HueRotation filter class\n * @example\n * const filter = new HueRotation({\n * rotation: -0.5\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class HueRotation extends ColorMatrix<\n 'HueRotation',\n HueRotationOwnProps,\n HueRotationSerializedProps\n> {\n /**\n * HueRotation value, from -1 to 1.\n */\n declare rotation: HueRotationOwnProps['rotation'];\n\n static type = 'HueRotation';\n\n static defaults = hueRotationDefaultValues;\n\n calculateMatrix() {\n const rad = this.rotation * Math.PI,\n cosine = cos(rad),\n sine = sin(rad),\n aThird = 1 / 3,\n aThirdSqtSin = Math.sqrt(aThird) * sine,\n OneMinusCos = 1 - cosine;\n this.matrix = [\n cosine + OneMinusCos / 3,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n aThird * OneMinusCos - aThirdSqtSin,\n 0,\n 0,\n aThird * OneMinusCos - aThirdSqtSin,\n aThird * OneMinusCos + aThirdSqtSin,\n cosine + aThird * OneMinusCos,\n 0,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n ];\n }\n\n isNeutralState() {\n return this.rotation === 0;\n }\n\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n this.calculateMatrix();\n super.applyTo(options);\n }\n\n toObject() {\n return {\n type: this.type,\n rotation: this.rotation,\n };\n }\n}\n\nclassRegistry.setClass(HueRotation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/invert';\n\nexport type InvertOwnProps = {\n alpha: boolean;\n invert: boolean;\n};\n\nexport const invertDefaultValues: InvertOwnProps = {\n alpha: false,\n invert: true,\n};\n\n/**\n * @example\n * const filter = new Invert();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Invert extends BaseFilter<'Invert', InvertOwnProps> {\n /**\n * Invert also alpha.\n * @param {Boolean} alpha\n * @default\n **/\n declare alpha: InvertOwnProps['alpha'];\n\n /**\n * Filter invert. if false, does nothing\n * @param {Boolean} invert\n * @default\n */\n declare invert: InvertOwnProps['invert'];\n\n static type = 'Invert';\n\n static defaults = invertDefaultValues;\n\n static uniformLocations = ['uInvert', 'uAlpha'];\n\n /**\n * Apply the Invert operation to a Uint8Array representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8Array to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n for (let i = 0; i < data.length; i += 4) {\n data[i] = 255 - data[i];\n data[i + 1] = 255 - data[i + 1];\n data[i + 2] = 255 - data[i + 2];\n\n if (this.alpha) {\n data[i + 3] = 255 - data[i + 3];\n }\n }\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Invert filter isNeutralState implementation\n * Used only in image applyFilters to discard filters that will not have an effect\n * on the image\n * @param {Object} options\n **/\n isNeutralState() {\n return !this.invert;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1i(uniformLocations.uInvert, Number(this.invert));\n gl.uniform1i(uniformLocations.uAlpha, Number(this.alpha));\n }\n}\n\nclassRegistry.setClass(Invert);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/noise';\n\nexport type NoiseOwnProps = {\n noise: number;\n};\n\nexport const noiseDefaultValues: NoiseOwnProps = {\n noise: 0,\n};\n\n/**\n * Noise filter class\n * @example\n * const filter = new Noise({\n * noise: 700\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class Noise extends BaseFilter<'Noise', NoiseOwnProps> {\n /**\n * Noise value, from\n * @param {Number} noise\n * @default\n */\n declare noise: NoiseOwnProps['noise'];\n\n static type = 'Noise';\n\n static defaults = noiseDefaultValues;\n\n static uniformLocations = ['uNoise', 'uSeed'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Brightness operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const noise = this.noise;\n for (let i = 0; i < data.length; i += 4) {\n const rand = (0.5 - Math.random()) * noise;\n data[i] += rand;\n data[i + 1] += rand;\n data[i + 2] += rand;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uNoise, this.noise / 255);\n gl.uniform1f(uniformLocations.uSeed, Math.random());\n }\n\n isNeutralState() {\n return this.noise === 0;\n }\n}\n\nclassRegistry.setClass(Noise);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/pixelate';\n\nexport type PixelateOwnProps = {\n blocksize: number;\n};\n\nexport const pixelateDefaultValues: PixelateOwnProps = {\n blocksize: 4,\n};\n\n/**\n * Pixelate filter class\n * @example\n * const filter = new Pixelate({\n * blocksize: 8\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Pixelate extends BaseFilter<'Pixelate', PixelateOwnProps> {\n declare blocksize: PixelateOwnProps['blocksize'];\n\n static type = 'Pixelate';\n\n static defaults = pixelateDefaultValues;\n\n static uniformLocations = ['uBlocksize'];\n\n /**\n * Apply the Pixelate operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data, width, height } }: T2DPipelineState) {\n for (let i = 0; i < height; i += this.blocksize) {\n for (let j = 0; j < width; j += this.blocksize) {\n const index = i * 4 * width + j * 4;\n const r = data[index];\n const g = data[index + 1];\n const b = data[index + 2];\n const a = data[index + 3];\n\n for (let _i = i; _i < Math.min(i + this.blocksize, height); _i++) {\n for (let _j = j; _j < Math.min(j + this.blocksize, width); _j++) {\n const index = _i * 4 * width + _j * 4;\n data[index] = r;\n data[index + 1] = g;\n data[index + 2] = b;\n data[index + 3] = a;\n }\n }\n }\n }\n }\n\n /**\n * Indicate when the filter is not gonna apply changes to the image\n **/\n isNeutralState() {\n return this.blocksize === 1;\n }\n\n protected getFragmentSource(): string {\n return fragmentSource;\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uBlocksize, this.blocksize);\n }\n}\n\nclassRegistry.setClass(Pixelate);\n","export const fragmentShader = `\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`;\n","import { classRegistry } from '../ClassRegistry';\nimport { Color } from '../color/Color';\nimport { BaseFilter } from './BaseFilter';\nimport { fragmentShader } from './shaders/removeColor';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\n\nexport type RemoveColorOwnProps = {\n color: string;\n distance: number;\n useAlpha: boolean;\n};\n\nexport const removeColorDefaultValues: RemoveColorOwnProps = {\n color: '#FFFFFF',\n distance: 0.02,\n useAlpha: false,\n};\n\n/**\n * Remove white filter class\n * @example\n * const filter = new RemoveColor({\n * threshold: 0.2,\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n * canvas.renderAll();\n */\nexport class RemoveColor extends BaseFilter<\n 'RemoveColor',\n RemoveColorOwnProps\n> {\n /**\n * Color to remove, in any format understood by {@link Color}.\n * @param {String} type\n * @default\n */\n declare color: RemoveColorOwnProps['color'];\n\n /**\n * distance to actual color, as value up or down from each r,g,b\n * between 0 and 1\n **/\n declare distance: RemoveColorOwnProps['distance'];\n\n /**\n * For color to remove inside distance, use alpha channel for a smoother deletion\n * NOT IMPLEMENTED YET\n **/\n declare useAlpha: RemoveColorOwnProps['useAlpha'];\n\n static type = 'RemoveColor';\n\n static defaults = removeColorDefaultValues;\n\n static uniformLocations = ['uLow', 'uHigh'];\n\n getFragmentSource() {\n return fragmentShader;\n }\n\n /**\n * Applies filter to canvas element\n * @param {Object} canvasEl Canvas element to apply filter to\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const distance = this.distance * 255,\n source = new Color(this.color).getSource(),\n lowC = [source[0] - distance, source[1] - distance, source[2] - distance],\n highC = [\n source[0] + distance,\n source[1] + distance,\n source[2] + distance,\n ];\n\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n\n if (\n r > lowC[0] &&\n g > lowC[1] &&\n b > lowC[2] &&\n r < highC[0] &&\n g < highC[1] &&\n b < highC[2]\n ) {\n data[i + 3] = 0;\n }\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n const source = new Color(this.color).getSource(),\n distance = this.distance,\n lowC = [\n 0 + source[0] / 255 - distance,\n 0 + source[1] / 255 - distance,\n 0 + source[2] / 255 - distance,\n 1,\n ],\n highC = [\n source[0] / 255 + distance,\n source[1] / 255 + distance,\n source[2] / 255 + distance,\n 1,\n ];\n gl.uniform4fv(uniformLocations.uLow, lowC);\n gl.uniform4fv(uniformLocations.uHigh, highC);\n }\n}\n\nclassRegistry.setClass(RemoveColor);\n","import { BaseFilter } from './BaseFilter';\nimport type {\n T2DPipelineState,\n TWebGLPipelineState,\n TWebGLUniformLocationMap,\n} from './typedefs';\nimport { isWebGLPipelineState } from './utils';\nimport { classRegistry } from '../ClassRegistry';\nimport { createCanvasElement } from '../util/misc/dom';\nimport type { XY } from '../Point';\n\nexport type TResizeType = 'bilinear' | 'hermite' | 'sliceHack' | 'lanczos';\n\nexport type ResizeOwnProps = {\n resizeType: TResizeType;\n scaleX: number;\n scaleY: number;\n lanczosLobes: number;\n};\n\nexport const resizeDefaultValues: ResizeOwnProps = {\n resizeType: 'hermite',\n scaleX: 1,\n scaleY: 1,\n lanczosLobes: 3,\n};\n\ntype ResizeDuring2DResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n};\n\ntype ResizeDuringWEBGLResize = Resize & {\n rcpScaleX: number;\n rcpScaleY: number;\n horizontal: boolean;\n width: number;\n height: number;\n taps: number[];\n tempScale: number;\n dH: number;\n dW: number;\n};\n\n/**\n * Resize image filter class\n * @example\n * const filter = new Resize();\n * object.filters.push(filter);\n * object.applyFilters(canvas.renderAll.bind(canvas));\n */\nexport class Resize extends BaseFilter<'Resize', ResizeOwnProps> {\n /**\n * Resize type\n * for webgl resizeType is just lanczos, for canvas2d can be:\n * bilinear, hermite, sliceHack, lanczos.\n * @default\n */\n declare resizeType: ResizeOwnProps['resizeType'];\n\n /**\n * Scale factor for resizing, x axis\n * @param {Number} scaleX\n * @default\n */\n declare scaleX: ResizeOwnProps['scaleX'];\n\n /**\n * Scale factor for resizing, y axis\n * @param {Number} scaleY\n * @default\n */\n declare scaleY: ResizeOwnProps['scaleY'];\n\n /**\n * LanczosLobes parameter for lanczos filter, valid for resizeType lanczos\n * @param {Number} lanczosLobes\n * @default\n */\n declare lanczosLobes: ResizeOwnProps['lanczosLobes'];\n\n static type = 'Resize';\n\n static defaults = resizeDefaultValues;\n\n static uniformLocations = ['uDelta', 'uTaps'];\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n this: ResizeDuringWEBGLResize,\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform2fv(\n uniformLocations.uDelta,\n this.horizontal ? [1 / this.width, 0] : [0, 1 / this.height],\n );\n gl.uniform1fv(uniformLocations.uTaps, this.taps);\n }\n\n getFilterWindow(this: ResizeDuringWEBGLResize) {\n const scale = this.tempScale;\n return Math.ceil(this.lanczosLobes / scale);\n }\n\n getCacheKey(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return `${this.type}_${filterWindow}`;\n }\n\n getFragmentSource(this: ResizeDuringWEBGLResize): string {\n const filterWindow = this.getFilterWindow();\n return this.generateShader(filterWindow);\n }\n\n getTaps(this: ResizeDuringWEBGLResize) {\n const lobeFunction = this.lanczosCreate(this.lanczosLobes),\n scale = this.tempScale,\n filterWindow = this.getFilterWindow(),\n taps = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n taps[i - 1] = lobeFunction(i * scale);\n }\n return taps;\n }\n\n /**\n * Generate vertex and shader sources from the necessary steps numbers\n * @param {Number} filterWindow\n */\n generateShader(filterWindow: number) {\n const offsets = new Array(filterWindow);\n for (let i = 1; i <= filterWindow; i++) {\n offsets[i - 1] = `${i}.0 * uDelta`;\n }\n return `\n precision highp float;\n uniform sampler2D uTexture;\n uniform vec2 uDelta;\n varying vec2 vTexCoord;\n uniform float uTaps[${filterWindow}];\n void main() {\n vec4 color = texture2D(uTexture, vTexCoord);\n float sum = 1.0;\n ${offsets\n .map(\n (offset, i) => `\n color += texture2D(uTexture, vTexCoord + ${offset}) * uTaps[${i}] + texture2D(uTexture, vTexCoord - ${offset}) * uTaps[${i}];\n sum += 2.0 * uTaps[${i}];\n `,\n )\n .join('\\n')}\n gl_FragColor = color / sum;\n }\n `;\n }\n\n applyToForWebgl(this: ResizeDuringWEBGLResize, options: TWebGLPipelineState) {\n options.passes++;\n this.width = options.sourceWidth;\n this.horizontal = true;\n this.dW = Math.round(this.width * this.scaleX);\n this.dH = options.sourceHeight;\n this.tempScale = this.dW / this.width;\n this.taps = this.getTaps();\n options.destinationWidth = this.dW;\n super.applyTo(options);\n options.sourceWidth = options.destinationWidth;\n\n this.height = options.sourceHeight;\n this.horizontal = false;\n this.dH = Math.round(this.height * this.scaleY);\n this.tempScale = this.dH / this.height;\n this.taps = this.getTaps();\n options.destinationHeight = this.dH;\n super.applyTo(options);\n options.sourceHeight = options.destinationHeight;\n }\n\n /**\n * Apply the resize filter to the image\n * Determines whether to use WebGL or Canvas2D based on the options.webgl flag.\n *\n * @param {Object} options\n * @param {Number} options.passes The number of filters remaining to be executed\n * @param {Boolean} options.webgl Whether to use webgl to render the filter.\n * @param {WebGLTexture} options.sourceTexture The texture setup as the source to be filtered.\n * @param {WebGLTexture} options.targetTexture The texture where filtered output should be drawn.\n * @param {WebGLRenderingContext} options.context The GL context used for rendering.\n * @param {Object} options.programCache A map of compiled shader programs, keyed by filter type.\n */\n applyTo(options: TWebGLPipelineState | T2DPipelineState) {\n if (isWebGLPipelineState(options)) {\n (this as unknown as ResizeDuringWEBGLResize).applyToForWebgl(options);\n } else {\n (this as unknown as ResizeDuring2DResize).applyTo2d(options);\n }\n }\n\n isNeutralState() {\n return this.scaleX === 1 && this.scaleY === 1;\n }\n\n lanczosCreate(lobes: number) {\n return (x: number) => {\n if (x >= lobes || x <= -lobes) {\n return 0.0;\n }\n if (x < 1.1920929e-7 && x > -1.1920929e-7) {\n return 1.0;\n }\n x *= Math.PI;\n const xx = x / lobes;\n return ((Math.sin(x) / x) * Math.sin(xx)) / xx;\n };\n }\n\n applyTo2d(this: ResizeDuring2DResize, options: T2DPipelineState) {\n const imageData = options.imageData,\n scaleX = this.scaleX,\n scaleY = this.scaleY;\n\n this.rcpScaleX = 1 / scaleX;\n this.rcpScaleY = 1 / scaleY;\n\n const oW = imageData.width;\n const oH = imageData.height;\n const dW = Math.round(oW * scaleX);\n const dH = Math.round(oH * scaleY);\n let newData: ImageData;\n\n if (this.resizeType === 'sliceHack') {\n newData = this.sliceByTwo(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'hermite') {\n newData = this.hermiteFastResize(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'bilinear') {\n newData = this.bilinearFiltering(options, oW, oH, dW, dH);\n } else if (this.resizeType === 'lanczos') {\n newData = this.lanczosResize(options, oW, oH, dW, dH);\n } else {\n // this should never trigger, is here just for safety net.\n newData = new ImageData(dW, dH);\n }\n options.imageData = newData;\n }\n\n /**\n * Filter sliceByTwo\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n sliceByTwo(\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const imageData = options.imageData;\n const mult = 0.5;\n let doneW = false;\n let doneH = false;\n let stepW = oW * mult;\n let stepH = oH * mult;\n const resources = options.filterBackend.resources;\n let sX = 0;\n let sY = 0;\n const dX = oW;\n let dY = 0;\n if (!resources.sliceByTwo) {\n resources.sliceByTwo = createCanvasElement();\n }\n const tmpCanvas = resources.sliceByTwo;\n if (tmpCanvas.width < oW * 1.5 || tmpCanvas.height < oH) {\n tmpCanvas.width = oW * 1.5;\n tmpCanvas.height = oH;\n }\n const ctx = tmpCanvas.getContext('2d')!;\n ctx.clearRect(0, 0, oW * 1.5, oH);\n ctx.putImageData(imageData, 0, 0);\n\n dW = Math.floor(dW);\n dH = Math.floor(dH);\n\n while (!doneW || !doneH) {\n oW = stepW;\n oH = stepH;\n if (dW < Math.floor(stepW * mult)) {\n stepW = Math.floor(stepW * mult);\n } else {\n stepW = dW;\n doneW = true;\n }\n if (dH < Math.floor(stepH * mult)) {\n stepH = Math.floor(stepH * mult);\n } else {\n stepH = dH;\n doneH = true;\n }\n ctx.drawImage(tmpCanvas, sX, sY, oW, oH, dX, dY, stepW, stepH);\n sX = dX;\n sY = dY;\n dY += stepH;\n }\n return ctx.getImageData(sX, sY, dW, dH);\n }\n\n /**\n * Filter lanczosResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n lanczosResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ): ImageData {\n function process(u: number): ImageData {\n let v, i, weight, idx, a, red, green, blue, alpha, fX, fY;\n center.x = (u + 0.5) * ratioX;\n icenter.x = Math.floor(center.x);\n for (v = 0; v < dH; v++) {\n center.y = (v + 0.5) * ratioY;\n icenter.y = Math.floor(center.y);\n a = 0;\n red = 0;\n green = 0;\n blue = 0;\n alpha = 0;\n for (i = icenter.x - range2X; i <= icenter.x + range2X; i++) {\n if (i < 0 || i >= oW) {\n continue;\n }\n fX = Math.floor(1000 * Math.abs(i - center.x));\n if (!cacheLanc[fX]) {\n cacheLanc[fX] = {};\n }\n for (let j = icenter.y - range2Y; j <= icenter.y + range2Y; j++) {\n if (j < 0 || j >= oH) {\n continue;\n }\n fY = Math.floor(1000 * Math.abs(j - center.y));\n if (!cacheLanc[fX][fY]) {\n cacheLanc[fX][fY] = lanczos(\n Math.sqrt(\n Math.pow(fX * rcpRatioX, 2) + Math.pow(fY * rcpRatioY, 2),\n ) / 1000,\n );\n }\n weight = cacheLanc[fX][fY];\n if (weight > 0) {\n idx = (j * oW + i) * 4;\n a += weight;\n red += weight * srcData[idx];\n green += weight * srcData[idx + 1];\n blue += weight * srcData[idx + 2];\n alpha += weight * srcData[idx + 3];\n }\n }\n }\n idx = (v * dW + u) * 4;\n destData[idx] = red / a;\n destData[idx + 1] = green / a;\n destData[idx + 2] = blue / a;\n destData[idx + 3] = alpha / a;\n }\n\n if (++u < dW) {\n return process(u);\n } else {\n return destImg;\n }\n }\n\n const srcData = options.imageData.data,\n destImg = options.ctx.createImageData(dW, dH),\n destData = destImg.data,\n lanczos = this.lanczosCreate(this.lanczosLobes),\n ratioX = this.rcpScaleX,\n ratioY = this.rcpScaleY,\n rcpRatioX = 2 / this.rcpScaleX,\n rcpRatioY = 2 / this.rcpScaleY,\n range2X = Math.ceil((ratioX * this.lanczosLobes) / 2),\n range2Y = Math.ceil((ratioY * this.lanczosLobes) / 2),\n cacheLanc: Record> = {},\n center: XY = { x: 0, y: 0 },\n icenter: XY = { x: 0, y: 0 };\n\n return process(0);\n }\n\n /**\n * bilinearFiltering\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n bilinearFiltering(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n let a;\n let b;\n let c;\n let d;\n let x;\n let y;\n let i;\n let j;\n let xDiff;\n let yDiff;\n let chnl;\n let color;\n let offset = 0;\n let origPix;\n const ratioX = this.rcpScaleX;\n const ratioY = this.rcpScaleY;\n const w4 = 4 * (oW - 1);\n const img = options.imageData;\n const pixels = img.data;\n const destImage = options.ctx.createImageData(dW, dH);\n const destPixels = destImage.data;\n for (i = 0; i < dH; i++) {\n for (j = 0; j < dW; j++) {\n x = Math.floor(ratioX * j);\n y = Math.floor(ratioY * i);\n xDiff = ratioX * j - x;\n yDiff = ratioY * i - y;\n origPix = 4 * (y * oW + x);\n\n for (chnl = 0; chnl < 4; chnl++) {\n a = pixels[origPix + chnl];\n b = pixels[origPix + 4 + chnl];\n c = pixels[origPix + w4 + chnl];\n d = pixels[origPix + w4 + 4 + chnl];\n color =\n a * (1 - xDiff) * (1 - yDiff) +\n b * xDiff * (1 - yDiff) +\n c * yDiff * (1 - xDiff) +\n d * xDiff * yDiff;\n destPixels[offset++] = color;\n }\n }\n }\n return destImage;\n }\n\n /**\n * hermiteFastResize\n * @param {Object} canvasEl Canvas element to apply filter to\n * @param {Number} oW Original Width\n * @param {Number} oH Original Height\n * @param {Number} dW Destination Width\n * @param {Number} dH Destination Height\n * @returns {ImageData}\n */\n hermiteFastResize(\n this: ResizeDuring2DResize,\n options: T2DPipelineState,\n oW: number,\n oH: number,\n dW: number,\n dH: number,\n ) {\n const ratioW = this.rcpScaleX,\n ratioH = this.rcpScaleY,\n ratioWHalf = Math.ceil(ratioW / 2),\n ratioHHalf = Math.ceil(ratioH / 2),\n img = options.imageData,\n data = img.data,\n img2 = options.ctx.createImageData(dW, dH),\n data2 = img2.data;\n for (let j = 0; j < dH; j++) {\n for (let i = 0; i < dW; i++) {\n const x2 = (i + j * dW) * 4;\n let weight = 0;\n let weights = 0;\n let weightsAlpha = 0;\n let gxR = 0;\n let gxG = 0;\n let gxB = 0;\n let gxA = 0;\n const centerY = (j + 0.5) * ratioH;\n for (let yy = Math.floor(j * ratioH); yy < (j + 1) * ratioH; yy++) {\n const dy = Math.abs(centerY - (yy + 0.5)) / ratioHHalf,\n centerX = (i + 0.5) * ratioW,\n w0 = dy * dy;\n for (let xx = Math.floor(i * ratioW); xx < (i + 1) * ratioW; xx++) {\n let dx = Math.abs(centerX - (xx + 0.5)) / ratioWHalf;\n const w = Math.sqrt(w0 + dx * dx);\n /* eslint-disable max-depth */\n if (w > 1 && w < -1) {\n continue;\n }\n //hermite filter\n weight = 2 * w * w * w - 3 * w * w + 1;\n if (weight > 0) {\n dx = 4 * (xx + yy * oW);\n //alpha\n gxA += weight * data[dx + 3];\n weightsAlpha += weight;\n //colors\n if (data[dx + 3] < 255) {\n weight = (weight * data[dx + 3]) / 250;\n }\n gxR += weight * data[dx];\n gxG += weight * data[dx + 1];\n gxB += weight * data[dx + 2];\n weights += weight;\n }\n /* eslint-enable max-depth */\n }\n }\n data2[x2] = gxR / weights;\n data2[x2 + 1] = gxG / weights;\n data2[x2 + 2] = gxB / weights;\n data2[x2 + 3] = gxA / weightsAlpha;\n }\n }\n return img2;\n }\n}\n\nclassRegistry.setClass(Resize);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/saturation';\n\nexport type SaturationOwnProps = {\n saturation: number;\n};\n\nexport const saturationDefaultValues: SaturationOwnProps = {\n saturation: 0,\n};\n\n/**\n * Saturate filter class\n * @example\n * const filter = new Saturation({\n * saturation: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Saturation extends BaseFilter<'Saturation', SaturationOwnProps> {\n /**\n * Saturation value, from -1 to 1.\n * Increases/decreases the color saturation.\n * A value of 0 has no effect.\n *\n * @param {Number} saturation\n * @default\n */\n declare saturation: SaturationOwnProps['saturation'];\n\n static type = 'Saturation';\n\n static defaults = saturationDefaultValues;\n\n static uniformLocations = ['uSaturation'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Saturation operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.saturation;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n data[i] += max !== r ? (max - r) * adjust : 0;\n data[i + 1] += max !== g ? (max - g) * adjust : 0;\n data[i + 2] += max !== b ? (max - b) * adjust : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {Object} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uSaturation, -this.saturation);\n }\n\n isNeutralState() {\n return this.saturation === 0;\n }\n}\n\nclassRegistry.setClass(Saturation);\n","export const fragmentSource = `\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`;\n","import { BaseFilter } from './BaseFilter';\nimport type { T2DPipelineState, TWebGLUniformLocationMap } from './typedefs';\nimport { classRegistry } from '../ClassRegistry';\nimport { fragmentSource } from './shaders/vibrance';\n\nexport type VibranceOwnProps = {\n vibrance: number;\n};\n\nexport const vibranceDefaultValues: VibranceOwnProps = {\n vibrance: 0,\n};\n\n/**\n * Vibrance filter class\n * @example\n * const filter = new Vibrance({\n * vibrance: 1\n * });\n * object.filters.push(filter);\n * object.applyFilters();\n */\nexport class Vibrance extends BaseFilter<'Vibrance', VibranceOwnProps> {\n /**\n * Vibrance value, from -1 to 1.\n * Increases/decreases the saturation of more muted colors with less effect on saturated colors.\n * A value of 0 has no effect.\n *\n * @param {Number} vibrance\n * @default\n */\n declare vibrance: VibranceOwnProps['vibrance'];\n\n static type = 'Vibrance';\n\n static defaults = vibranceDefaultValues;\n\n static uniformLocations = ['uVibrance'];\n\n getFragmentSource() {\n return fragmentSource;\n }\n\n /**\n * Apply the Vibrance operation to a Uint8ClampedArray representing the pixels of an image.\n *\n * @param {Object} options\n * @param {ImageData} options.imageData The Uint8ClampedArray to be filtered.\n */\n applyTo2d({ imageData: { data } }: T2DPipelineState) {\n const adjust = -this.vibrance;\n for (let i = 0; i < data.length; i += 4) {\n const r = data[i];\n const g = data[i + 1];\n const b = data[i + 2];\n const max = Math.max(r, g, b);\n const avg = (r + g + b) / 3;\n const amt = ((Math.abs(max - avg) * 2) / 255) * adjust;\n data[i] += max !== r ? (max - r) * amt : 0;\n data[i + 1] += max !== g ? (max - g) * amt : 0;\n data[i + 2] += max !== b ? (max - b) * amt : 0;\n }\n }\n\n /**\n * Send data from this filter to its shader program's uniforms.\n *\n * @param {WebGLRenderingContext} gl The GL canvas context used to compile this filter's shader.\n * @param {TWebGLUniformLocationMap} uniformLocations A map of string uniform names to WebGLUniformLocation objects\n */\n sendUniformData(\n gl: WebGLRenderingContext,\n uniformLocations: TWebGLUniformLocationMap,\n ) {\n gl.uniform1f(uniformLocations.uVibrance, -this.vibrance);\n }\n\n isNeutralState() {\n return this.vibrance === 0;\n }\n}\n\nclassRegistry.setClass(Vibrance);\n","// First we set the env variable\n\nimport { setEnv } from './src/env';\nimport { getEnv, getNodeCanvas } from './src/env/node';\n\nsetEnv(getEnv());\n\n// After the env is set we can export everything and expose specific node functionality\n\nimport type { JpegConfig, PngConfig } from 'canvas';\nimport {\n Canvas as CanvasBase,\n StaticCanvas as StaticCanvasBase,\n} from './fabric';\nimport { FabricObject } from './src/shapes/Object/Object';\n\nFabricObject.ownDefaults.objectCaching = false;\n\nexport * from './fabric';\n\nexport class StaticCanvas extends StaticCanvasBase {\n getNodeCanvas() {\n return getNodeCanvas(this.getElement());\n }\n createPNGStream(opts?: PngConfig) {\n return this.getNodeCanvas().createPNGStream(opts);\n }\n createJPEGStream(opts?: JpegConfig) {\n return this.getNodeCanvas().createJPEGStream(opts);\n }\n}\n\n/**\n * **NOTICE**:\n * {@link Canvas} is designed for interactivity.\n * Therefore, using it in node has no benefit.\n * Use {@link StaticCanvas} instead.\n */\nexport class Canvas extends CanvasBase {\n getNodeCanvas() {\n return getNodeCanvas(this.getElement());\n }\n createPNGStream(opts?: PngConfig) {\n return this.getNodeCanvas().createPNGStream(opts);\n }\n createJPEGStream(opts?: JpegConfig) {\n return this.getNodeCanvas().createJPEGStream(opts);\n }\n}\n"],"names":["BaseConfiguration","constructor","_defineProperty","window","devicePixelRatio","Configuration","config","configure","arguments","length","undefined","Object","assign","addFonts","paths","fontPaths","_objectSpread","removeFonts","fontFamilys","forEach","fontFamily","clearFonts","restoreDefaults","keys","defaults","reduce","acc","key","log","severity","_len","optionalParams","Array","_key","console","FabricError","Error","message","options","concat","SignalAbortedError","context","GLProbe","WebGLProbe","testPrecision","gl","precision","fragmentSource","fragmentShader","createShader","FRAGMENT_SHADER","shaderSource","compileShader","getShaderParameter","COMPILE_STATUS","queryWebGL","canvas","getContext","maxTextureSize","getParameter","MAX_TEXTURE_SIZE","GLPrecision","find","getExtension","loseContext","isSupported","textureSize","copyPasteData","getEnv","document","isTouchSupported","navigator","maxTouchPoints","dispose","env","setEnv","value","getBrowserEnv","getFabricDocument","getFabricWindow","getDevicePixelRatio","_config$devicePixelRa","Math","max","NodeGLProbe","implForWrapper","jsdomImplForWrapper","utils","JSDOMWindow","JSDOM","decodeURIComponent","resources","pretendToBeVisual","getNodeCanvas","canvasEl","impl","_canvas","_image","element","_currentSrc","_attributes","_classList","Cache","getFontCache","_ref","fontStyle","fontWeight","toLowerCase","charWidthsCache","fontCache","cacheKey","clearFontCache","limitDimsByArea","ar","perfLimitSizeTotal","roughWidth","sqrt","floor","cache","VERSION","version","noop","halfPI","PI","twoMathPi","PiBy180","iMatrix","freeze","DEFAULT_SVG_FONT_SIZE","ALIASING_LIMIT","kRect","CENTER","LEFT","TOP","BOTTOM","RIGHT","NONE","reNewline","MOVING","SCALING","ROTATING","ROTATE","SKEWING","RESIZING","MODIFY_POLY","MODIFY_PATH","CHANGED","SCALE","SCALE_X","SCALE_Y","SKEW_X","SKEW_Y","FILL","STROKE","MODIFIED","JSON","SVG","ClassRegistry","Map","has","classType","getClass","get","setClass","classConstructor","set","type","getSVGClass","SVGTagName","setSVGClass","classRegistry","AnimationRegistry","remove","index","indexOf","splice","cancelAll","animations","animation","abort","cancelByCanvas","filter","_animation$target","target","cancelByTarget","runningAnimations","Observable","on","arg0","handler","__eventListeners","entries","eventName","off","push","once","disposers","_ref2","d","disposer","onceHandler","args","call","_removeEventListener","eventListener","_ref3","fire","_this$__eventListener","listenersForEvent","i","removeFromArray","array","idx","cos","angle","angleSlice","abs","sin","sign","Point","y","x","add","that","addEquals","scalarAdd","scalar","scalarAddEquals","subtract","subtractEquals","scalarSubtract","scalarSubtractEquals","multiply","scalarMultiply","scalarMultiplyEquals","divide","scalarDivide","scalarDivideEquals","eq","lt","lte","gt","gte","lerp","t","min","distanceFrom","dx","dy","midPointFrom","toString","setXY","setX","setY","setFromPoint","swap","clone","rotate","radians","origin","ZERO","sinus","cosinus","p","rotated","transform","ignoreOffset","isCollection","fabricObject","isArray","_objects","createCollectionMixin","Base","Collection","_onObjectAdded","object","_onObjectRemoved","_onStackOrderChanged","objects","size","insertAt","_len2","_key2","removed","_len3","_key3","forEachObject","callback","getObjects","_len4","types","_key4","o","isType","item","isEmpty","contains","deep","includes","some","obj","complexity","memo","current","sendObjectToBack","unshift","bringObjectToFront","sendObjectBackwards","intersecting","newIdx","findNewLowerIndex","bringObjectForward","findNewUpperIndex","moveObjectTo","isOverlapping","collectObjects","left","top","width","height","includeIntersecting","tl","br","selectable","visible","intersectsWithRect","isContainedWithinRect","containsPoint","CommonMethods","_setOptions","prop","_setObject","_set","toggle","property","requestAnimFrame","requestAnimationFrame","cancelAnimFrame","handle","cancelAnimationFrame","id","uid","createCanvasElement","createElement","createImage","copyCanvasElement","_newCanvas$getContext","newCanvas","createCanvasElementFor","drawImage","toDataURL","format","quality","isHTMLCanvas","degreesToRadians","degrees","radiansToDegrees","isIdentityMatrix","mat","every","transformPoint","invertTransform","a","r","multiplyTransformMatrices","b","is2x2","multiplyTransformMatrixArray","matrices","reduceRight","product","curr","calcPlaneRotation","atan2","qrDecompose","denom","pow","scaleX","scaleY","skewX","skewY","translateX","translateY","createTranslateMatrix","createRotateMatrix","angleRadiant","cosValue","sinValue","createScaleMatrix","angleToSkew","tan","createSkewXMatrix","skewValue","createSkewYMatrix","calcDimensionsMatrix","flipX","flipY","matrix","composeMatrix","scaleMatrix","loadImage","url","signal","crossOrigin","Promise","resolve","reject","aborted","img","err","src","addEventListener","done","onload","onerror","removeEventListener","enlivenObjects","reviver","instances","all","map","fromObject","then","fabricInstance","catch","error","instance","finally","enlivenObjectEnlivables","serializedObject","promises","values","enlived","pick","source","pickBy","predicate","ColorNameMap","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","reRGBa","reHSLa","reHex","hue2rgb","q","rgb2Hsl","g","maxValue","minValue","h","s","l","round","fromAlphaToFloat","parseFloat","endsWith","hexify","toUpperCase","padStart","greyAverage","avg","Color","color","setSource","_source","_tryParsingColor","sourceFromHex","sourceFromRgb","sourceFromHsl","isUnrecognised","getSource","toRgb","toRgba","join","toHsl","toHsla","toHex","fullHex","toHexa","slice","getAlpha","setAlpha","alpha","toGrayscale","toBlackWhite","threshold","average","bOrW","overlayWith","otherColor","otherAlpha","otherSource","R","G","B","fromRgb","fromRgba","match","parsedValue","fromHsl","fromHsla","match1degrees","parseAngletoDegrees","fromHex","isShortNotation","expandedValue","split","hex","hexCouple","parseInt","lowercase","numeric","toFixed","number","fractionDigits","Number","getSvgAttributes","commonAttributes","parseUnit","fontSize","unit","exec","dpi","DPI","parseAlign","align","parsePreserveAspectRatioAttribute","attribute","firstPart","secondPart","trim","alignX","alignY","meetOrSlice","matrixToSVG","NUM_FRACTION_DIGITS","colorPropToSVG","inlineStyle","colorValue","opacityValue","toLive","opacity","createSVGRect","svgColor","w","isFiller","filler","isSerializableFiller","toObject","isPattern","offsetX","isTextObject","_renderText","isPath","_renderPathCommands","isActiveSelection","getScrollLeftTop","doc","getDocumentFromElement","elementLoop","docElement","documentElement","body","scrollLeft","scrollTop","parentNode","host","nodeType","style","position","el","ownerDocument","getWindowFromElement","_el$ownerDocument","defaultView","setCanvasDimensions","ctx","retinaScaling","setAttribute","scale","setCSSDimensions","getElementOffset","_getWindowFromElement","offset","elemStyle","getComputedStyle","borderLeftWidth","borderTopWidth","paddingLeft","paddingTop","box","docElem","getBoundingClientRect","scrollLeftTop","clientLeft","clientTop","makeElementUnselectable","onselectstart","userSelect","StaticCanvasDOMManager","createLowerCanvas","lower","getElementById","hasAttribute","_originalCanvasStyle","cssText","classList","cleanupDOM","removeAttribute","setDimensions","calcOffset","staticCanvasDefaults","backgroundVpt","backgroundColor","overlayVpt","overlayColor","includeDefaultValues","svgViewportTransformation","renderOnAddRemove","skipOffscreen","enableRetinaScaling","imageSmoothingEnabled","controlsAboveOverlay","allowTouchScrolling","viewportTransform","StaticCanvas","lowerCanvasEl","_this$elements$lower","elements","contextContainer","_this$elements$lower2","getDefaults","ownDefaults","initElements","_setDimensionsImpl","skipControlsDrawing","calcViewportBoundaries","requestRenderAll","setCoords","getRetinaScaling","_offset","getWidth","getHeight","setWidth","setHeight","dimensions","cssOnly","backstoreOnly","hasLostContext","getZoom","setViewportTransform","vpt","zoomToPoint","point","before","newPoint","after","setZoom","absolutePan","relativePan","getElement","clearContext","clearRect","clear","backgroundImage","overlayImage","renderAll","cancelRequestedRender","destroyed","renderCanvas","renderAndReset","nextRenderHandle","disposed","iVpt","vptCoords","tr","bl","drawControls","_ctx","v","path","clipPath","patternQuality","_renderBackground","save","_renderObjects","restore","shouldCache","_transformDone","renderCache","forClipping","drawClipPathOnCanvas","_renderOverlay","__cleanupTask","globalCompositeOperation","zoomX","zoomY","_cacheCanvas","cacheTranslationX","cacheTranslationY","len","render","_renderBackgroundOrOverlay","fill","needsVpt","isAFiller","beginPath","moveTo","lineTo","closePath","fillStyle","offsetY","m","gradientTransform","patternTransform","getCenter","getCenterPoint","centerObjectH","_centerObject","centerObjectV","centerObject","viewportCenterObject","getVpCenter","viewportCenterObjectH","viewportCenterObjectV","center","toDatalessJSON","propertiesToInclude","toDatalessObject","_toObjectMethod","toJSON","methodName","clipPathData","excludeFromExport","_toObject","__serializeBgOverlay","originalValue","data","bgImage","bgColor","background","overlay","toSVG","markup","_setSVGPreamble","_setSVGHeader","clipPathId","_setSVGBgOverlayColor","_setSVGBgOverlayImage","_setSVGObjects","suppressPreamble","encoding","optViewBox","viewBox","createSVGFontFacesMarkup","createSVGRefElementsMarkup","createSVGClipPathMarkup","toClipPathSVG","shouldTransform","additionalTransform","fontList","styles","styleRow","fontListMarkup","_setSVGObject","bgOrOverlay","repeat","finalWidth","finalHeight","shouldInvert","loadFromJSON","json","serialized","parse","enlivedMap","properties","cloneWithoutData","multiplier","finalMultiplier","toCanvasElement","scaledWidth","scaledHeight","zoom","originalWidth","originalHeight","originalSkipControlsDrawing","newZoom","vp","newVp","originalRetina","objectsToRender","task","destroy","kill","touchEvents","getTouchInfo","event","touchProp","changedTouches","getPointer","scroll","_evt","clientX","clientY","isTouchEvent","pointerType","stopEvent","e","preventDefault","stopPropagation","makeBoundingBoxFromPoints","points","removeTransformFromObject","inverted","finalTransform","calcOwnMatrix","applyTransformToObject","addTransformToObject","_qrDecompose","otherOptions","_objectWithoutProperties","_excluded","setPositionByOrigin","resetObjectTransform","saveObjectTransform","sizeAfterTransform","dimX","dimY","bbox","calcPlaneChangeMatrix","from","to","sendPointToPlane","sendVectorToPlane","sendObjectToPlane","fireEvent","_target$canvas","originOffset","bottom","right","resolveOrigin","originValue","NOT_ALLOWED_CURSOR","getActionFromCorner","alreadySelected","corner","control","controls","getActionName","isTransformCentered","originX","originY","invertOrigin","isLocked","lockingKey","commonEventInfo","eventData","pointer","findCornerQuadrant","getTotalAngle","cornerAngle","normalizePoint","getRelativeCenterPoint","translateToGivenOrigin","p2","getLocalPoint","padding","localPoint","dragHandler","newLeft","newTop","moveX","moveY","FabricObjectSVGExportMixin","getSvgStyles","skipShadow","fillRule","strokeWidth","strokeDashArray","strokeDashOffset","strokeLineCap","strokeLineJoin","strokeMiterLimit","visibility","getSvgFilter","stroke","shadow","getSvgCommons","getSvgTransform","full","calcTransformMatrix","svgTransform","_toSVG","_reviver","_createBaseSVGMarkup","_createBaseClipPathSVGMarkup","objectMarkup","commonPieces","noStyle","withShadow","styleInfo","shadowInfo","vectorEffect","strokeUniform","absoluteClipPath","absolutePositioned","clipPathMarkup","addPaintOrder","paintFirst","getSvgRegex","arr","RegExp","reNum","String","raw","_templateObject","_taggedTemplateLiteral","svgNS","reFontDeclaration","svgValidTagNames","svgViewBoxElements","svgInvalidAncestors","svgValidParents","attributesMap","cx","cy","display","fSize","cPath","svgValidTagNamesRegEx","svgViewBoxElementsRegEx","svgValidParentsRegEx","reViewBoxAttrValue","unitVectorX","zero","rotateVector","vector","createVector","magnitude","calcAngleBetweenVectors","crossProduct","dotProduct","calcVectorRotation","getUnitVector","getOrthonormalVector","counterClockwise","isBetweenVectors","AxB","AxT","BxT","shadowOffsetRegex","reOffsetsAndBlur","shadowDefaultValues","blur","affectStroke","nonScaling","Shadow","parseShadow","shadowStr","replace","BLUR_BOX","fBoxX","fBoxY","capValue","stateProperties","cacheProperties","fabricObjectDefaultValues","minScaleLimit","objectCaching","centeredRotation","centeredScaling","dirty","interactiveObjectDefaultValues","noScaleCache","lockMovementX","lockMovementY","lockRotation","lockScalingX","lockScalingY","lockSkewingX","lockSkewingY","lockScalingFlip","cornerSize","touchCornerSize","transparentCorners","cornerColor","cornerStrokeColor","cornerStyle","cornerDashArray","hasControls","borderColor","borderDashArray","borderOpacityWhenMoving","borderScaleFactor","hasBorders","selectionBackgroundColor","evented","perPixelTargetFind","activeOn","hoverCursor","moveCursor","normalize","c","asin","elastic","defaultEasing","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInElastic","normA","normS","normP","easeOutElastic","normC","easeInOutElastic","easeInBack","easeOutBack","easeInOutBack","easeOutBounce","easeInBounce","easeInOutBounce","easeInQuad","easeOutQuad","easeInOutQuad","defaultAbort","AnimationBase","startValue","byValue","duration","delay","easing","onStart","onChange","onComplete","tick","bind","_onStart","_onChange","_onComplete","_abort","endValue","calculate","state","_state","isDone","start","firstTick","timestamp","startTime","Date","register","setTimeout","durationMs","boundDurationMs","durationProgress","valueProgress","unregister","ValueAnimation","timeElapsed","ArrayAnimation","defaultColorEasing","wrapColorCallback","rgba","ColorAnimation","startColor","endColor","isArrayAnimation","animate","animateColor","Intersection","status","append","isPointContained","T","A","infinite","AB","AT","isPointInPolygon","other","hits","inter","intersectSegmentSegment","intersectLineLine","a1","a2","b1","b2","aInfinite","bInfinite","a2xa1x","a2ya1y","b2xb1x","b2yb1y","a1xb1x","a1yb1y","uaT","ubT","uB","ua","ub","segmentsCoincide","intersectSegmentLine","s1","s2","l1","l2","intersectLinePolygon","result","intersectSegmentPolygon","intersectPolygonPolygon","points1","points2","coincidences","intersectPolygonRectangle","r1","r2","topRight","bottomLeft","ObjectGeometry","getX","getXY","getY","getRelativeX","setRelativeX","getRelativeY","setRelativeY","relativePosition","getRelativeXY","group","setRelativeXY","isStrokeAccountedForInDimensions","getCoords","aCoords","calcACoords","coords","intersection","intersectsWithObject","isContainedWithinObject","getBoundingRect","isOnScreen","isPartiallyOnScreen","allPointsAreOutside","getScaledWidth","_getTransformedDimensions","getScaledHeight","scaleToWidth","boundingRectFactor","scaleToHeight","getCanvasRetinaScaling","_this$canvas","getViewportTransform","_this$canvas2","rotateMatrix","tMatrix","finalMatrix","dim","transformMatrixKey","skipGroup","prefix","matrixCache","ownMatrixCache","_getNonTransformedDimensions","_calculateCurrentDimensions","dimOptions","preScalingStrokeValue","postScalingStrokeValue","noSkew","finalDimensions","fromOriginX","fromOriginY","toOriginX","toOriginY","translateToCenterPoint","translateToOriginPoint","relCenter","getPointByOrigin","pos","_getLeftTopCoords","FabricObject","name","setOptions","_createCacheCanvas","_cacheContext","_updateCacheCanvas","_limitCacheSize","dims","maxCacheSideLimit","minCacheSideLimit","limX","limY","capped","_getCacheCanvasDimensions","objectScale","getTotalObjectScaling","neededX","neededY","ceil","dimensionsChanged","zoomChanged","shouldRedraw","setTransform","drawingWidth","drawingHeight","translate","needFullTransform","contextTop","getObjectScaling","retina","getObjectOpacity","_constrainScale","isChanged","parent","isNotVisible","_setupCompositeOperation","drawSelectionBackground","_setOpacity","_setShadow","drawCacheOnCanvas","_removeCacheCanvas","drawObject","isCacheDirty","parentClipPaths","hasStroke","hasFill","needsItsOwnCache","ownCaching","isOnACache","willDrawShadow","drawClipPathOnCache","canvasWithClipPath","originalFill","originalStroke","_setClippingProperties","_render","_drawClipPath","createClipPathLayer","prevClipPath","skipCanvas","fillRect","_removeShadow","globalAlpha","_setStrokeStyles","decl","lineWidth","lineCap","lineDashOffset","lineJoin","miterLimit","gradientUnits","_applyPatternForTransformedGradient","strokeStyle","_applyPatternGradientTransform","_setFillStyles","_setLineDash","dashArray","setLineDash","sx","sy","multX","multY","scaling","shadowColor","shadowBlur","browserShadowBlurConstant","shadowOffsetX","shadowOffsetY","_renderPaintInOrder","_renderStroke","_renderFill","_pCtx$createPattern","pCanvas","pCtx","createPattern","_findCenterFromElement","objectForm","cloneAsImage","ImageClass","origParams","originalGroup","originalShadow","canvasProvider","withoutTransform","withoutShadow","boundingRect","shadowOffset","originalCanvas","setOnGroup","animatable","_animate","propIsColor","colorProperties","animationOptions","isDescendantOf","getAncestors","ancestors","findCommonAncestors","fork","otherFork","common","otherAncestors","ancestor","j","hasCommonAncestors","commonAncestors","isInFrontOf","ancestorData","firstCommonAncestor","headOfFork","pop","headOfOtherFork","thisIndex","otherIndex","propertiesToSerialize","customProperties","toFixedBound","val","_removeDefaultValues","hasStaticDefaultValues","baseValues","getPrototypeOf","baseValue","_fromObject","serializedObjectOptions","_ref4","extraParam","_excluded2","enlivedObjectOptions","wrapWithFireEvent","actionHandler","extraEventInfo","actionPerformed","wrapWithFixedAnchor","centerPoint","constraint","changeObjectWidth","strokePadding","oldWidth","newWidth","changeWidth","renderCircleControl","styleOverride","xSize","sizeX","ySize","sizeY","myLeft","myTop","arc","renderSquareControl","xSizeBy2","ySizeBy2","strokeRect","Control","shouldActivate","controlKey","_fabricObject$canvas","getActiveObject","isControlVisible","getActionHandler","getMouseDownHandler","mouseDownHandler","getMouseUpHandler","mouseUpHandler","cursorStyleHandler","cursorStyle","actionName","getVisibility","_fabricObject$_contro","_fabricObject$_contro2","_controlsVisibility","setVisibility","positionHandler","currentControl","calcCornerCoords","objectCornerSize","centerX","centerY","isTouch","touchSizeX","touchSizeY","rotationStyleHandler","rotateObjectWithSnapping","ex","ey","theta","pivotPoint","lastAngle","curAngle","snapAngle","snapThreshold","rightAngleLocked","leftAngleLocked","hasRotated","rotationWithSnapping","scaleIsProportional","uniformIsToggled","uniScaleKey","uniformScaling","scalingIsForbidden","by","scaleProportionally","lockX","lockY","scaleMap","scaleCursorStyleHandler","n","scaleObject","forbidScaling","signX","signY","gestureScale","distance","original","originalDistance","oldScaleX","oldScaleY","scaleObjectFromCorner","scaleObjectX","scaleObjectY","scalingEqually","scalingX","scalingY","AXIS_KEYS","counterAxis","skew","lockSkewing","flip","skewMap","skewCursorStyleHandler","skewObject","axis","skewingSide","skewKey","skewingBefore","skewingStart","shearingStart","shearing","skewing","atan","changed","dimBefore","dimAfter","compensationFactor","skewHandler","originKey","lockSkewingKey","flipKey","counterOriginKey","counterFlipKey","counterOriginFactor","skewingDirection","finalHandler","skewHandlerX","skewHandlerY","isAltAction","altActionKey","scaleOrSkewActionName","isAlternative","scaleSkewCursorStyleHandler","scalingXOrSkewingY","scalingYOrSkewingX","createObjectDefaultControls","ml","mr","mb","mt","mtr","withConnection","createResizeControls","createTextboxDefaultControls","InteractiveFabricObject","createControls","targetCanvas","_currentTransform","action","startsWith","getActiveControl","__corner","coord","oCoords","findControl","forTouch","cornerEntries","touchCorner","calcOCoords","rMatrix","positionMatrix","startMatrix","transformOptions","forEachControl","_calcCornerCoords","fn","_activeObject","wh","strokeBorders","_drawBorders","drawControlsConnectingLines","_renderControls","styleOptions","shouldDrawBorders","shouldDrawControls","isMoving","drawBorders","forActiveSelection","shouldStroke","setControlVisible","setControlsVisibility","clearContextTop","restoreManually","onDeselect","_options","onSelect","shouldStartDragging","_e","onDragStart","canDrop","renderDragSourceEffect","renderDropTargetEffect","applyMixins","derivedCtor","constructors","baseCtor","getOwnPropertyNames","prototype","defineProperty","getOwnPropertyDescriptor","create","isTransparent","tolerance","getImageData","alphaChannel","rotatePoint","findIndexRight","StrokeProjectionsBase","strokeProjectionMagnitude","strokeUniformScalar","createSideVector","projectOrthogonally","applySkew","calcOrthogonalProjection","isSkewed","scaleUnitVector","unitVector","zeroVector","StrokeLineJoinProjections","getOrthogonalRotationFactor","vector1","vector2","C","AC","bisector","orthogonalProjection","correctSide","projectBevel","projections","projectMiter","hypotUnitScalar","miterVector","projectRoundNoSkew","startCircle","endCircle","radiusOnAxisX","radiusOnAxisY","projectRoundWithSkew","circleRadius","newY","furthestY","newX","furthestX","projectRound","isStraightLine","newOrigin","proj0","proj1","comparisonVector","isProj0Start","projectPoints","project","originPoint","projectedPoint","StrokeLineCapProjections","projectButt","projection","projectSquare","strokePointingOut","projectedA","projectStrokeOnPoints","openPath","reduced","cloneStyles","newObj","keyInner","capitalize","string","firstLetterOnly","charAt","escapeXml","graphemeSplit","textstring","graphemes","chr","getWholeChar","str","code","charCodeAt","isNaN","next","prev","hasStyleChanged","prevStyle","thisStyle","forTextSpans","textBackgroundColor","deltaY","overline","underline","linethrough","stylesToArray","text","textLines","stylesArray","charIndex","chars","end","stylesFromArray","stylesObject","styleIndex","SHARED_ATTRIBUTES","selectorMatches","selector","nodeName","classNames","getAttribute","azAz","matcher","splitClassNames","doesSomeParentMatch","selectors","parentMatching","parentElement","elementMatchesRule","firstMatching","getGlobalStylesForElement","cssRules","rule","normalizeAttr","attr","_attributesMap","regex","cleanupSvgAttribute","attributeValue","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","transforms","transformList","_templateObject7","reTransformList","reTransform","reTransformAll","parseTransformAttribute","test","matchAll","transformMatch","matchedParams","operation","rawArgs","arg1","arg2","arg3","arg4","arg5","arg","normalizeValue","parentAttributes","parsed","ouputValue","transformMatrix","fillIndex","strokeIndex","parseFontDeclaration","oStyle","lineHeight","parseStyleObject","parseStyleString","chunk","parseStyleAttribute","colorAttributesMap","setStrokeFillOpacity","attributes","colorAttr","parseAttributes","parentFontSize","ownAttributes","normalizedStyle","normalizedAttr","normalizedValue","font","mergedAttrs","rectDefaultValues","rx","ry","RECT_PROPS","Rect","_initRxRy","isRounded","bezierCurveTo","fromElement","_parseAttributes","ATTRIBUTE_NAMES","restOfparsedAttributes","Boolean","LAYOUT_TYPE_INITIALIZATION","LAYOUT_TYPE_ADDED","LAYOUT_TYPE_REMOVED","LAYOUT_TYPE_IMPERATIVE","LAYOUT_TYPE_OBJECT_MODIFIED","LAYOUT_TYPE_OBJECT_MODIFYING","getObjectBounds","destinationGroup","currentGroup","objectCenter","accountForStroke","strokeUniformVector","scalingStrokeWidth","sizeVector","LayoutStrategy","calcLayoutResult","shouldPerformLayout","calcBoundingBox","prevStrategy","strategy","shouldLayoutClipPath","getInitialSize","overrides","bboxSize","bboxLeftTop","bboxCenter","actualSize","relativeCorrection","FitContentLayout","LAYOUT_MANAGER","LayoutManager","_subscriptions","performLayout","strictContext","bubbles","_prevLayoutStrategy","onBeforeLayout","layoutResult","getLayoutResult","commitLayout","onAfterLayout","attachHandlers","trigger","subscribe","unsubscribe","_context","delete","unsubscribeTargets","targets","subscribeTargets","tricklingContext","layoutManager","prevCenter","nextCenter","correction","layoutObjects","_context$x","_context$y","layoutObject","_","bubblingContext","NoopLayoutManager","groupDefaultValues","subTargetCheck","interactive","Group","groupInit","_options$layoutManage","__objectSelectionTracker","__objectSelectionMonitor","__objectSelectionDisposer","enterGroup","canEnterGroup","_filterObjectsBeforeEnteringGroup","allowedObjects","_onAfterObjectsChange","removeParentTransform","exitGroup","_shouldSetNestedCoords","removeAll","_activeObjects","selected","activeObjects","_watchObject","watch","_enterGroup","activeObject","_exitGroup","ownCache","preserveObjectStacking","triggerLayout","__serializeObjects","method","_includeDefaultValues","originalDefaults","_createSVGBgRect","fillStroke","commons","svgString","bg","abortable","hydratedOptions","layoutClass","strategyClass","groupSVGElements","findScaleToFit","destination","findScaleToCover","commaWsp","reArcCommandPoints","rePathCommand","repeatedCommands","M","segmentToBezier","theta1","theta2","cosTh","sinTh","cx1","cy1","mT","fromX","fromY","costh1","sinth1","costh2","sinth2","toX","toY","cp1X","cp1Y","cp2X","cp2Y","arcToSegments","large","sweep","rotateX","root","sinTheta","px","py","rx2","ry2","py2","px2","pl","_rx","_ry","mTheta","calcVectorAngle","dtheta","segments","mDelta","th3","ux","uy","vx","vy","ta","tb","CB1","CB2","CB3","CB4","getBoundsOfCurve","begx","begy","cp1x","cp1y","cp2x","cp2y","endx","endy","argsString","cachesBoundsOfCurve","boundsOfCurveCache","tvalues","bounds","b2ac","sqrtb2ac","t1","t2","jlen","iterator","getPointOnCubicBezierIterator","fromArcToBeziers","fx","fy","rot","tx","ty","segsNorm","makePathSimpler","x1","y1","destinationPath","previous","controlX","controlY","parsedCommand","converted","calcLineLength","x2","y2","pct","c1","c2","c3","c4","QB1","QB2","QB3","getTangentCubicIterator","p1x","p1y","p2x","p2y","p3x","p3y","p4x","p4y","qb1","qb2","qb3","tangentX","tangentY","getPointOnQuadraticBezierIterator","getTangentQuadraticIterator","invT","pathIterator","tempP","tmpLen","perc","findPercentageForDistance","segInfo","nextLen","nextStep","lastPerc","angleFinder","getPathSegmentsInfo","totalLength","tempInfo","info","basicInfo","command","destX","destY","getPointOnPath","infos","segPercent","segment","rePathCmdAll","regExpArcCommandPoints","reMyNum","commandLengths","parsePath","pathString","_pathString$match","chain","matchStr","commandLetter","commandLength","paramArr","lastIndex","out","newCommand","transformedCommand","getSmoothPathFromPoints","p1","multSignX","multSignY","manyPoints","midPoint","transformPath","pathOffset","pathSegment","newSegment","getRegularPolygonPath","numVertexes","radius","interiorAngle","rotationAdjustment","rad","joinPath","pathData","setStyle","elementStyle","setProperty","mergeClipPaths","_b$group","getRandomInt","random","request","xhr","XMLHttpRequest","removeListener","ontimeout","onreadystatechange","readyState","open","send","_assignTransformMatrixProps","removeTransformMatrixForSvgParsing","preserveAspectRatioOptions","cropX","cropY","offsetLeft","offsetTop","CanvasDOMManager","containerClass","upperCanvasEl","createUpperCanvas","upper","applyCanvasStyle","container","createContainerElement","replaceChild","className","removeChild","canvasDefaults","centeredKey","selection","selectionKey","selectionColor","selectionDashArray","selectionBorderColor","selectionLineWidth","selectionFullyContained","defaultCursor","freeDrawingCursor","notAllowedCursor","targetFindTolerance","skipTargetFind","stopContextMenu","fireRightClick","fireMiddleClick","enablePointerEvents","SelectableCanvas","_this$elements$upper","_this$elements$upper2","wrapperEl","_objectsToRender","deselected","_discardActiveObject","_hoveredTarget","_hoveredTargets","_chooseObjectsToRender","contextTopDirty","_groupSelector","isDrawingMode","renderTopLayer","_isCurrentlyDrawing","freeDrawingBrush","_drawSelection","renderTop","setTargetFindTolerance","pixelFindCanvasEl","pixelFindContext","isTargetTransparent","selectionBgc","enhancedTolerance","_isSelectionKeyPressed","sKey","_shouldClearSelection","getActiveObjects","_shouldCenterTransform","modifierKeyPressed","centerTransform","_getOriginFromCorner","controlName","_setupCurrentTransform","_control$getActionHan","getScenePoint","altKey","lastX","lastY","shiftKey","setCursor","cursor","deltaX","extent","strokeOffset","minX","minY","maxX","maxY","findTarget","getViewportPoint","aObjects","searchPossibleTargets","subTargets","altSelectionKey","_pointIsInObjectSelectionArea","viewportZoom","angleRadians","cosP","sinP","cosPSinP","cosPMinusSinP","_checkTarget","isEditing","_searchPossibleTargets","subTarget","_pointer","_absolutePointer","fromViewport","boundsWidth","boundsHeight","cssScale","_resetTransformEventData","_setBrushStyles","willReadFrequently","getTopContext","getSelectionContext","getSelectionElement","active","_fireSelectionEvents","oldObjects","somethingChanged","invalidate","added","setActiveObject","currentActives","_setActiveObject","prevActiveObject","endCurrentTransform","discardActiveObject","discarded","_finalizeCurrentTransform","_scaling","originalProperties","_realizeGroupTransformOnObject","layoutProps","originalValues","TextEditingManager","cb","hiddenTextarea","focus","__disposer","exitTextEditing","exitEditing","onMouseMove","_this$target","updateSelectionOnMouseMove","addEventOptions","passive","getEventPoints","viewportPoint","scenePoint","absolutePointer","addListener","syntheticEventConfig","mouse","in","targetIn","targetOut","canvasIn","canvasOut","drag","Canvas","eventHandler","addOrRemove","_getEventPrefix","functor","_eventjsFunctor","canvasElement","eventTypePrefix","_onResize","_onMouseDown","_onMouseMove","_onMouseOut","_onMouseEnter","_onMouseWheel","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragOver","_onDragEnter","_onDragLeave","_onDrop","_onTouchStart","removeListeners","_onMouseUp","_onTouchEnd","clearTimeout","_willAddMouseDown","__onMouseWheel","shared","nestedTarget","_isClick","_dragSource","_onDragProgress","_renderDragEffects","dropTarget","_dropTarget","didDrop","dataTransfer","dropEffect","dragSource","_draggedoverTarget","findDragTargets","eventType","_fireEnterLeaveEvents","_basicEventHandler","_cacheTransformEventData","_handleEvent","getPointerId","evt","identifier","pointerId","_isMainEvent","isPrimary","touches","mainTouchId","shouldPreventScrolling","currentActiveObject","__onMouseDown","_target","__onMouseUp","__onMouseMove","_shouldRender","_this$_activeObject","isClick","button","_onMouseUpInDrawingMode","shouldRender","targetWasActive","handleSelection","found","originalControl","originalMouseUpHandler","_setCursorFromEvent","currentTarget","currentSubTargets","_onMouseDownInDrawingMode","onMouseDown","_onMouseMoveInDrawingMode","onMouseUp","grouped","handleMultiSelection","groupSelector","_fireOverOutEvents","_transformObject","textEditingManager","fireSyntheticInOutEvents","oldTarget","fireCanvas","draggedoverTarget","targetChanged","outOpt","nextTarget","inOpt","previousTarget","localPointer","_performTransformAction","activeSelection","reverse","isAS","prevActiveObjects","multiSelectAdd","klass","newActiveSelection","point1","point2","collectedObjects","linearDefaultCoords","radialDefaultCoords","ifNaN","valueIfNaN","RE_PERCENT","isPercent","parsePercent","NaN","RE_KEY_VALUE_PAIRS","RE_KEY_VALUE","parseColorStop","keyValuePairs","parseColorStops","opacityAttr","colorStops","colorStopEls","getElementsByTagName","parseType","parseGradientUnits","convertPercentUnitsToValues","valuesToConvert","finalValue","propValue","getValue","parseLinearCoords","parseRadialCoords","parseCoords","Gradient","addColorStop","colorStop","preTransform","sort","needsSwap","minRadius","maxRadius","percentageShift","gradient","createLinearGradient","createRadialGradient","svgOptions","viewBoxWidth","viewBoxHeight","Pattern","isImageSource","isCanvasSource","sourceToString","complete","naturalWidth","naturalHeight","patternSource","patternOffsetX","patternOffsetY","patternWidth","patternHeight","BaseBrush","_saveAndTransform","needsFullRender","_resetShadow","_isOutSideCanvas","Path","_setPath","adjustPosition","setBoundingBox","_calcBoundsFromPath","quadraticCurveTo","pathCmd","sourcePath","_getOffsetTransform","digits","_calcDimensions","subpathStartX","subpathStartY","parsedAttributes","isEmptySVGPath","PencilBrush","_points","_hasStraightLine","drawSegment","drawStraightLine","straightLineKey","_prepareForDrawing","_addPoint","limitedToCanvasSize","oldEnd","_finalizeAndAddPath","_reset","convertPointsToSVGPath","createPath","decimatePoints","lastPoint","cDistance","adjustedDistance","newPoints","decimate","CIRCLE_PROPS","circleDefaultValues","startAngle","endAngle","Circle","setRadius","getRadiusX","getRadiusY","startX","startY","endX","endY","largeFlag","sweepFlag","otherParsedAttributes","CircleBrush","drawDot","addPoint","dot","originalRenderOnAddRemove","circles","circle","pointerPoint","getUniqueRects","rects","uniqueRects","uniqueRectsArray","SprayBrush","sprayChunks","sprayChunk","addSprayChunk","renderChunck","chunck","rect","optimizeOverlapping","sprayChunck","density","dotWidthVariance","dotWidth","randomOpacity","PatternBrush","getPatternSrc","dotDistance","patternCanvas","patternCtx","getPattern","pattern","topLeft","coordProps","Line","_setWidthHeight","calcLinePoints","origStrokeStyle","_this$stroke","_x1","_x2","_y1","_y2","xMult","yMult","triangleDefaultValues","Triangle","widthBy2","heightBy2","ellipseDefaultValues","ELLIPSE_PROPS","Ellipse","getRx","getRy","parsePointsAttribute","pointsSplit","parsedPoints","polylineDefaultValues","exactBoundingBox","Polyline","initialized","isOpen","_projectStrokeOnPoints","strokeDiff","bboxNoStroke","layoutProperties","_options$width","_options$height","_options$width2","_options$height2","output","diffX","diffY","Polygon","fontProperties","textDecorationProperties","textLayoutProperties","additionalProps","styleProperties","textDefaultValues","_reNewline","_reSpacesAndTabs","_reSpaceAndTab","_reWords","textAlign","superscript","baseline","subscript","pathStartOffset","pathSide","pathAlign","_fontSizeFraction","offsets","_fontSizeMult","charSpacing","direction","CACHE_FONT_SIZE","MIN_TEXT_WIDTH","JUSTIFY","JUSTIFY_LEFT","JUSTIFY_RIGHT","JUSTIFY_CENTER","StyledText","isEmptyStyles","lineIndex","line","p3","styleHas","cleanStyle","stylesCount","letterCount","stylePropertyValue","allStyleObjectPropertiesMatch","graphemeCount","styleObject","stylePropertyHasBeenSet","_textLines","removeStyle","lineNum","charNum","_extendStyles","get2DCursorLocation","_getLineStyle","_setLineStyle","newStyle","_getStyleDeclaration","_setStyleDeclaration","getSelectionStyles","startIndex","endIndex","getStyleAtPosition","getCompleteStyleDeclaration","setSelectionStyles","_forceClearCache","_lineStyle$charIndex","lineStyle","_styleProperties","_deleteStyleDeclaration","_deleteLineStyle","multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","TextSVGExportMixin","_getSVGLeftTopOffsets","textAndBg","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","lineTop","getHeightOfLine","textBgRects","textSpans","noShadow","textDecoration","getSvgTextDecoration","textTopOffset","textLeftOffset","lineOffset","_getLineLeftOffset","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","styleProps","getSvgSpanStyles","fillStyles","dySpan","isJustify","actualStyle","nextStyle","charsToRender","charBox","boxWidth","timeToRender","__charBounds","kernedWidth","leftOffset","heightOfLine","boxStart","currentColor","lastColor","getValueOfPropertyAt","_getSVGLineTopOffset","lineTopOffset","lastHeight","useWhiteSpace","decoration","measuringContext","getMeasuringContext","FabricText","setPathInfo","initDimensions","segmentsInfo","_splitText","newLines","_splitTextIntoLines","lines","graphemeLines","_unwrappedTextLines","_unwrappedLines","_text","graphemeText","_clearCache","calcTextWidth","cursorWidth","calcTextHeight","enlargeSpaces","diffSpace","currentLineWidth","numberOfSpaces","accumulatedSpace","charBound","spaces","isEndOfWrapping","getLineWidth","missingNewlineOffset","_lineIndex","selectionStart","skipWrapping","_setTextStyles","_renderTextLinesBackground","_renderTextDecoration","_renderTextStroke","_renderTextFill","charStyle","forMeasuring","textBaseline","_getFontDeclaration","maxWidth","_renderTextLine","_renderChars","_getLeftOffset","_getTopOffset","lineLeftOffset","drawStart","renderLeft","_measureChar","_char","previousChar","prevCharStyle","fontDeclaration","couple","stylesAreEqual","fontMultiplier","coupleWidth","previousWidth","measureText","getHeightOfChar","measureLine","lineInfo","_measureLine","_getWidthOfCharSpacing","prevGrapheme","graphemeInfo","llength","lineBounds","grapheme","_getGraphemeBox","positionInPath","totalPathLength","_setGraphemeOnPath","numOfSpaces","centerPosition","skipLeft","previousBox","__lineHeights","maxHeight","_renderTextCommon","lineHeights","shortCut","isLtr","currentDirection","drawingLeft","_renderChar","_applyPatternGradientTransformText","handleFiller","fullDecl","shouldFill","fillOffsets","fillText","strokeOffsets","strokeText","setSuperscript","_setScript","setSubscript","schema","loc","lineDiff","__lineWidths","_charStyle$property","topOffset","lastDecoration","lastFill","currentDecoration","currentFill","currentSize","currentDy","parsedFontFamily","genericFonts","newLine","newText","needsDims","isAddingPath","_options$parsedAttrib","textAnchor","restOfOptions","textContent","textHeightScaleFactor","lineHeightDiff","scaledDiff","textHeight","offX","DraggableTextDelegate","dragEnterHandler","dragOverHandler","dragLeaveHandler","dragEndHandler","dropHandler","_dispose","isPointerOverSelection","newSelection","getSelectionStartFromPointer","selectionEnd","__mouseDownInPlace","isActive","__dragStartFired","setCursorByClick","initDelayedCursor","__isDraggingOver","getDragStartSelection","__dragStartSelection","setDragImage","_e$dataTransfer","flipFactor","boundaries","_getCursorBoundaries","selectionPosition","diff","bgc","dragImage","border","__dragImageDisposer","appendChild","setData","stringify","effectAllowed","abortCursorAnimation","editable","defaultPrevented","dragStartSelection","targetCanDrop","ev","_e$dataTransfer2","insert","getData","trailing","selectionStartOffset","removeChars","trimEnd","insertChars","enterEditing","_updateTextarea","_e$dataTransfer3","reNonWord","ITextBehavior","initBehavior","_tick","_onTickComplete","_animateCursor","toValue","_currentCursorOpacity","renderCursorOrSelection","_currentTickState","cursorDuration","_this$_currentTickCom","_currentTickCompleteState","restart","cursorDelay","shouldClear","cursorAnimation","restartCursorIfNeeded","selectAll","_fireSelectionChanged","getSelectedText","findWordBoundaryLeft","startFrom","_reSpace","findWordBoundaryRight","findLineBoundaryLeft","findLineBoundaryRight","searchWordBoundary","selectWord","newSelectionStart","newSelectionEnd","selectLine","enterEditingImpl","initHiddenTextarea","_saveEditingProps","_setEditingProps","_textBeforeEdit","activeElement","currentStart","currentEnd","__selectionStartOnMouseDown","editingBorderColor","fromStringToGraphemeSelection","smallerTextStart","graphemeStart","smallerTextEnd","graphemeEnd","fromGraphemeToStringSelection","cursorOffsetCache","inCompositionMode","updateTextareaPosition","updateFromTextArea","textarea","_calcTextareaPosition","desiredPosition","compositionStart","cursorLocation","charHeight","upperCanvas","upperCanvasWidth","upperCanvasHeight","clientWidth","clientHeight","_savedProps","_restoreEditingProps","_exitEditing","exitEditingImpl","isTextChanged","_removeExtraneousStyles","removeStyleFromTo","lineStart","charStart","lineEnd","charEnd","styleObj","shiftLineStyles","numericChar","clonedStyles","numericLine","insertNewlineStyleObject","qty","copiedStyle","newLineStyles","originalLineLength","isEndOfLine","someStyleIsCarryingOver","currentCharStyle","numIndex","styleCarriedOver","insertCharStyleObject","quantity","currentLineStyles","currentLineStylesCloned","numericIndex","insertNewStyleBlock","insertedText","cursorLoc","addedLines","linesLength","setSelectionStartEndWithShift","_selectionDirection","ITextKeyBehavior","autocapitalize","autocorrect","autocomplete","spellcheck","wrap","hiddenTextareaContainer","keydown","keyup","input","copy","cut","paste","compositionstart","compositionupdate","compositionend","onKeyDown","keyMap","keysMapRtl","keysMap","keyCode","ctrlKeysMapDown","ctrlKey","metaKey","stopImmediatePropagation","onKeyUp","_copyDone","ctrlKeysMapUp","onInput","fromPaste","updateAndFire","nextText","charCount","nextCharCount","removedText","charDiff","removeFrom","removeTo","textareaSelection","backDelete","copiedText","disableStyleCopyPaste","copiedTextStyle","onCompositionStart","onCompositionEnd","onCompositionUpdate","compositionEnd","_getWidthBeforeCursor","widthBeforeCursor","bound","getDownCursorOffset","isRight","selectionProp","_getSelectionForOffset","indexOnOtherLine","_getIndexOnLine","textAfterCursor","getUpCursorOffset","textBeforeCursor","widthOfCharsOnLine","indexOnLine","charWidth","foundMatch","leftEdge","rightEdge","offsetFromLeftEdge","offsetFromRightEdge","moveCursorDown","_moveCursorUpOrDown","moveCursorUp","moveCursorWithShift","moveCursorWithoutShift","moveCursorLeft","_moveCursorLeftOrRight","_move","newValue","_moveLeft","_moveRight","moveCursorLeftWithoutShift","change","moveCursorLeftWithShift","moveCursorRight","moveCursorRightWithShift","moveCursorRightWithoutShift","notALeftClick","ITextClickBehavior","_mouseDownHandler","_mouseDownHandlerBefore","doubleClickHandler","tripleClickHandler","__lastClickTime","__lastLastClickTime","__lastPointer","draggableTextDelegate","__newClickTime","newPointer","isTripleClick","__lastSelected","didDrag","mouseOffset","charLength","widthAfter","MOVE_CURSOR_UP","MOVE_CURSOR_DOWN","MOVE_CURSOR_LEFT","MOVE_CURSOR_RIGHT","EXIT_EDITING","protectedDefaultValues","iTextDefaultValues","cursorColor","caching","IText","setSelectionStart","_updateAndFire","setSelectionEnd","renderCursor","renderSelection","skipCaching","_getCursorBoundariesOffsets","__getCursorBoundariesOffsets","renderCursorAt","_renderCursor","getCursorRenderingData","_renderSelection","dragSelection","startLine","endLine","startChar","endChar","realLineHeight","boxEnd","drawHeight","extraTop","drawWidth","compositionColor","getCurrentCharFontSize","cp","_getCurrentCharIndex","getCurrentCharColor","cursorPosition","textboxDefaultValues","minWidth","dynamicMinWidth","_wordJoiners","splitByGrapheme","Textbox","_styleMap","_generateStyleMap","textInfo","realLineCount","realLineCharCount","isWrapping","nextLineIndex","nextOffset","shouldLimit","mapNextLine","p2Number","_wrapText","desiredWidth","getGraphemeDataForRender","wrapped","wordsData","_wrapLine","infix","largestWordWidth","wordsOrGraphemes","wordSplit","word","graphemeArray","_measureWord","charOffset","reservedSpace","additionalSpace","infixWidth","lineJustStarted","wordWidth","getMinWidth","linesToKeep","propNumber","ClipPathLayout","clipPathCenter","FixedLayout","ActiveSelectionLayoutManager","parents","Set","selectedObjects","activeSelectionDefaultValues","multiSelectionStacking","ActiveSelection","findIndex","groups","childrenOverride","Canvas2dFilterBackend","applyFilters","filters","sourceElement","sourceWidth","sourceHeight","imageData","originalImageData","pipelineState","originalEl","filterBackend","applyTo","imageDataPostFilter","putImageData","WebGLFilterBackend","tileSize","Float32Array","setupGLContext","captureGPUInfo","createWebGLCanvas","glOptions","premultipliedAlpha","depth","stencil","antialias","clearColor","cachedTexture","getCachedTexture","destinationWidth","destinationHeight","sourceTexture","createTexture","targetTexture","originalTexture","passes","webgl","aPosition","programCache","pass","tempFbo","createFramebuffer","bindFramebuffer","FRAMEBUFFER","resizeCanvasIfNeeded","copyGLTo2D","bindTexture","TEXTURE_2D","deleteTexture","deleteFramebuffer","clearWebGLCaches","textureCache","textureImageSource","NEAREST","RGBA","UNSIGNED_BYTE","CLAMP_TO_EDGE","TEXTURE_MAG_FILTER","TEXTURE_MIN_FILTER","TEXTURE_WRAP_S","TEXTURE_WRAP_T","texture","texParameteri","texImage2D","uniqueId","evictCachesForKey","glCanvas","sourceY","copyGLTo2DPutImageData","dWidth","dHeight","numBytes","u8","Uint8Array","imageBuffer","u8Clamped","Uint8ClampedArray","readPixels","imgData","ImageData","gpuInfo","renderer","vendor","ext","UNMASKED_RENDERER_WEBGL","UNMASKED_VENDOR_WEBGL","initFilterBackend","enableGLFiltering","getFilterBackend","strict","setFilterBackend","backend","imageDefaultValues","srcFromAttribute","minimumScaleTrigger","imageSmoothing","IMAGE_PROPS","FabricImage","setElement","_element","removeTexture","_originalElement","CSS_CANVAS","resizeFilter","applyResizeFilters","elementKey","getCrossOrigin","getOriginalSize","_stroke","filterObj","getSrc","hasCrop","imageMarkup","strokeSvg","imageRendering","getSvgSrc","origFill","filtered","setSrc","minimumScale","elementToFilter","_filteredEl","_filterScalingX","_filterScalingY","_lastScaleX","_lastScaleY","isNeutralState","imgElement","_needsResize","elementToDraw","elWidth","elHeight","sX","sY","sW","sH","maxDestW","maxDestH","_resetWidthHeight","pAR","preserveAspectRatio","pWidth","pHeight","rWidth","rHeight","f","rf","hydratedProps","fromURL","imageOptions","applyViewboxTransform","viewBoxAttr","widthAttr","heightAttr","goodViewbox","missingViewBox","missingDimAttr","translateMatrix","widthDiff","heightDiff","parsedDim","pasedViewBox","createElementNS","firstChild","getTagName","node","tagName","svgInvalidAncestorsRegEx","hasInvalidAncestor","getMultipleNodes","nodeNames","nodeArray","nodeList","getElementsByTagNameNS","parseUseDirectives","nodelist","skipAttributes","useElement","useAttributes","useAttrMap","xlink","href","referencedElement","clonedOriginal","cloneNode","originalAttributes","originalAttrMap","currentTrans","el3","setAttributeNS","childNodes","styleRecord","mergedStyles","entry","gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","_gradient$getAttribut","xLink","referencedGradient","children","referenceClone","tagArray","getGradientDefs","elList","gradientDefs","getCSSRules","allRules","styleContents","ruleObj","declaration","propertyValuePairs","pair","_rule","findTag","ElementsParser","clipPaths","regexUrl","createObject","resolveGradient","resolveClipPath","extractPropertyDefinition","storage","gradientDef","usingElement","exactOwner","clipPathElements","objTransformInv","clipPathTag","clipPathOwner","clipPathElement","enlivedClippath","clipRule","gTransform","isValidSvgTag","createEmptyResponse","allElements","parseSVGDocument","descendants","localClipPaths","elementParser","loadSVGFromString","parser","DOMParser","parseFromString","loadSVGFromURL","xml","responseXML","parsedDoc","ACTION_NAME","createPolyPositionHandler","pointIndex","polyObject","polyActionHandler","poly","mouseLocalPosition","factoryPolyActionHandler","anchorPoint","anchorPointInParentPlane","newAnchorPointInParentPlane","createPolyActionHandler","createPolyControls","calcPathPointPosition","pathObject","commandIndex","movePathPoint","anchorCommand","pathPositionHandler","pathActionHandler","indexFromPrevCommand","previousCommandType","PathPointControl","controlFill","controlStroke","PathControlPointControl","connectToCommandIndex","connectToPointIndex","connectionDashArray","commandType","createControl","commandIndexPos","pointIndexPos","isControlPoint","controlPointStyle","pointStyle","createPathControls","isWebGLPipelineState","isPutImageFaster","sourceCanvas","ArrayBuffer","testContext","testPipelineState","performance","now","drawImageTime","putImageDataTime","highPsourceCode","identityFragmentShader","vertexSource","BaseFilter","getFragmentSource","getVertexSource","createProgram","vertexShader","VERTEX_SHADER","program","getShaderInfoLog","attachShader","linkProgram","getProgramParameter","LINK_STATUS","getProgramInfoLog","uniformLocations","getUniformLocations","uStepW","getUniformLocation","uStepH","attributeLocations","getAttributeLocations","getAttribLocation","locations","sendAttributeData","aPositionData","attributeLocation","buffer","createBuffer","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bufferData","STATIC_DRAW","_setupFrameBuffer","framebufferTexture2D","COLOR_ATTACHMENT0","finish","_swapTextures","temp","applyToWebGL","applyTo2d","getCacheKey","retrieveShader","shader","useProgram","uniform1f","sendUniformData","viewport","drawArrays","TRIANGLE_STRIP","bindAdditionalTexture","textureUnit","activeTexture","TEXTURE0","unbindAdditionalTexture","_gl","_uniformLocations","createHelpLayer","helpLayer","defaultKeys","filterOptions","blendColorFragmentSource","screen","difference","lighten","darken","exclusion","tint","blendColorDefaultValues","mode","BlendColor","tg","alpha1","oR","oG","oB","uniform4fv","uColor","mask","blendImageDefaultValues","BlendImage","image","TEXTURE1","calculateMatrix","blendImage","canvas1","blendData","uniform1i","uImage","uniformMatrix3fv","uTransformMatrix","enlivedImage","blurDefaultValues","Blur","aspectRatio","horizontal","simpleBlur","blurLayer1","blurLayer2","canvas2","ctx1","ctx2","nSamples","percent","newImageData","delta","chooseRightDelta","uniform2fv","uDelta","blurScale","brightnessDefaultValues","brightness","Brightness","uBrightness","colorMatrixDefaultValues","colorsOnly","ColorMatrix","constants","uniformMatrix4fv","uColorMatrix","uConstants","createColorMatrixFilter","_Class","newClass","Brownie","Vintage","Kodachrome","Technicolor","Polaroid","Sepia","BlackWhite","Composed","subFilters","enlivedFilters","contrastDefaultValues","contrast","Contrast","contrastF","uContrast","Convolute_3_1","Convolute_3_0","Convolute_5_1","Convolute_5_0","Convolute_7_1","Convolute_7_0","Convolute_9_1","Convolute_9_0","convoluteDefaultValues","opaque","Convolute","weights","side","halfSide","sw","sh","createImageData","dst","alphaFac","dstOff","scx","scy","srcOff","wt","uniform1fv","uMatrix","GAMMA","gammaDefaultValues","gamma","Gamma","rInv","gInv","bInv","rgbValues","rgb","uniform3fv","uGamma","lightness","luminosity","grayscaleDefaultValues","Grayscale","uMode","hueRotationDefaultValues","rotation","HueRotation","cosine","sine","aThird","aThirdSqtSin","OneMinusCos","invertDefaultValues","invert","Invert","uInvert","uAlpha","noiseDefaultValues","noise","Noise","rand","uNoise","uSeed","pixelateDefaultValues","blocksize","Pixelate","_i","_j","uBlocksize","removeColorDefaultValues","useAlpha","RemoveColor","lowC","highC","uLow","uHigh","resizeDefaultValues","resizeType","lanczosLobes","Resize","uTaps","taps","getFilterWindow","tempScale","filterWindow","generateShader","getTaps","lobeFunction","lanczosCreate","applyToForWebgl","dW","dH","lobes","xx","rcpScaleX","rcpScaleY","oW","oH","newData","sliceByTwo","hermiteFastResize","bilinearFiltering","lanczosResize","mult","doneW","doneH","stepW","stepH","dX","dY","tmpCanvas","process","u","weight","fX","fY","ratioX","icenter","ratioY","range2X","cacheLanc","range2Y","lanczos","rcpRatioX","rcpRatioY","srcData","destData","destImg","xDiff","yDiff","chnl","origPix","w4","pixels","destImage","destPixels","ratioW","ratioH","ratioWHalf","ratioHHalf","img2","data2","weightsAlpha","gxR","gxG","gxB","gxA","yy","w0","saturationDefaultValues","saturation","Saturation","adjust","uSaturation","vibranceDefaultValues","vibrance","Vibrance","amt","uVibrance","StaticCanvasBase","createPNGStream","opts","createJPEGStream","CanvasBase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAMA,iBAAiB,CAAC;EAAAC,WAAA,GAAA;AACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbEC,IAAAA,eAAA,oCAc4B,CAAC,CAAA,CAAA;AAE7B;AACF;AACA;AAFEA,IAAAA,eAAA,cAGM,EAAE,CAAA,CAAA;AA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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,MACpB,kJAAkJ,CAAA;;AAEpJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,MAAM,GAAGA,MACpB,kKAAkK,CAAA;;AAEpK;AACA;AACA;AACO,MAAMC,KAAK,GAAGA,MAAM,2CAA2C;;AC/GtE;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CAACrU,CAAS,EAAEsU,CAAS,EAAEzV,CAAS,KAAa;EAClE,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;EACA,IAAIA,CAAC,GAAG,CAAC,EAAE;AACTA,IAAAA,CAAC,IAAI,CAAC,CAAA;AACR,GAAA;AACA,EAAA,IAAIA,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IACb,OAAOmB,CAAC,GAAG,CAACsU,CAAC,GAAGtU,CAAC,IAAI,CAAC,GAAGnB,CAAC,CAAA;AAC5B,GAAA;AACA,EAAA,IAAIA,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACb,IAAA,OAAOyV,CAAC,CAAA;AACV,GAAA;AACA,EAAA,IAAIzV,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;AACb,IAAA,OAAOmB,CAAC,GAAG,CAACsU,CAAC,GAAGtU,CAAC,KAAK,CAAC,GAAG,CAAC,GAAGnB,CAA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M;AACnBC,EAAAA,UAAU,EAAE,MAAM;AAClBmiC,EAAAA,aAAa,EAAE,SAAS;AACxBC,EAAAA,iBAAiB,EAAE,WAAW;AAC9BC,EAAAA,gBAAgB,EAAE,aAAa;AAE/BxiC,EAAAA,kBAAkB,EAAE,KAAK;AACzByiC,EAAAA,mBAAmB,EAAE,CAAC;AACtBC,EAAAA,cAAc,EAAE,KAAK;AAErBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,cAAc,EAAE,KAAK;AACrBC,EAAAA,eAAe,EAAE,KAAK;AACtBC,EAAAA,mBAAmB,EAAE,KAAK;AAE1B3B,EAAAA,cAAc,EAAE,kBAAkB;AAElC5N,EAAAA,sBAAsB,EAAE,KAAA;AAC1B,CAAC;;ACnPD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMwP,gBAAgB,SACnBn6C,cAAY,CAEtB;EAAAjwB,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAAO,SAAA,CAAA,CAAA;AAGE;AAQA;AAUA;AASA;AAKA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AAKE;AAKA;AACF;AACA;AACA;AAHEN,IAAAA,eAAA,kBAI0B,EAAE,CAAA,CAAA;AAS5B;AACF;AACA;AACA;AACA;AAJEA,IAAAA,eAAA,0BAKkC,EA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C,gBAAgBA,CAACD,IAAiB,EAAE;IAClC,OAAO,IAAI,CAACjoH,aAAa,EAAE,CAACkoH,gBAAgB,CAACD,IAAI,CAAC,CAAA;AACpD,GAAA;AACF,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM/7C,MAAM,SAASi8C,QAAU,CAAC;AACrCnoH,EAAAA,aAAaA,GAAG;AACd,IAAA,OAAOA,aAAa,CAAC,IAAI,CAACwsB,UAAU,EAAE,CAAC,CAAA;AACzC,GAAA;EACAw7F,eAAeA,CAACC,IAAgB,EAAE;IAChC,OAAO,IAAI,CAACjoH,aAAa,EAAE,CAACgoH,eAAe,CAACC,IAAI,CAAC,CAAA;AACnD,GAAA;EACAC,gBAAgBA,CAACD,IAAiB,EAAE;IAClC,OAAO,IAAI,CAACjoH,aAAa,EAAE,CAACkoH,gBAAgB,CAACD,IAAI,CAAC,CAAA;AACpD,GAAA;AACF;;;;"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c21d3909bdb..58dfb76e805 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fabric", - "version": "6.5.1", + "version": "6.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "fabric", - "version": "6.5.1", + "version": "6.5.2", "license": "MIT", "devDependencies": { "@babel/cli": "^7.22.9", diff --git a/package.json b/package.json index b1da0e83070..6085c67c446 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "fabric", "description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.", "homepage": "http://fabricjs.com/", - "version": "6.5.1", + "version": "6.5.2", "author": "Juriy Zaytsev ", "contributors": [ {